Objects which are near to us appear to be moving in opposite directions because they very move very quickly from our vision . The objects which are very far remain in our vision for a longer period of time and therefore it seems that they are moving along with us.
For e.g - Imagine yourself sitting in a car . Create an imaginary line from your eye to the object. The tree near you moves very fast whereas the mountain peak you can see from far remains in your vision for a long preiod of time and it seems to us the mountain is moving with you.