The solution is simple: Don't use compatibility mode.
You can prevent IE from using compatibility mode by specifying thX-UA-Compatible
meta tag, as follows:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" >
Put that in your header and IE will stop using compatibility mode (unless the user sets it manually, of course; can't do much about that!)
It is important to note that compatibility mode is not actually 100% the same as a real copy of IE7. It has a number of bugs and quirks that do not appear in the real thing. You didn't specify whether your problems are occurring in a real IE7 or not, but if you need your site to support IE7, you should test with a real copy of IE7, not IE8's compatibility mode. (You can install all versions of IE together using a tool like IETester, which is great for cross-version testing)
Also, just in case you're confusing 'compatibility mode' with 'quirks mode', I should mention that you should make sure you have a valid doctype at the top of your page. This should do the trick:
<!DOCTYPE html>
Hope that helps.