Of course OpenCV i appropriate for this but it's hard problem. Don't worry, there are solutions based on mono cam (for example mobileeye or I've seen some android apps).
There are plenty of ways to do this and you can experiment a lot, so good starting point is to read papers, I recommend work of Marcos Nieto ( http://marcosnieto.net/ ), good stuff there.
Basically you need to locate and recognize car ahead of you, and then you could try to estimate distance by bounding box size / perimeter / ... . You probably need to classify car to size categories and some machine learning may be involved.
Another way is to use bird-eye projection (just a simple perspective transform) on lane, but in this case may be hard (it will need calibration).
Start reading some articles on the topic. Car detection, collision avoidance, lane detection are some directions to read. You'll have a much better idea on where to start then.