I have a problem with MarginTop... Here the Code: .... <title>Unbenanntes Dokument</title> <style type="text/css"> <!-- #main { background-color: #336600; height: 200px; } #middle { background-color: #33CC33; height: 100px; margin-top: 50px; } --> </style> </head> <body> <div id="main"> <div id="middle"></div> </div> </body> HTML: Difference: I need the IE Version for Firefox...
try using padding-top to the main division instead of margin-top in "middle" division <style type="text/css"> <!-- *{ margin:0; padding:0; } #main { background-color: #336600; padding-top:50px; height: 150px; } #middle { background-color: #33CC33; height: 100px; } --> </style>
thank you. ill try it after work... Which is the best way to solve css problems? Testing first on IE and then correction for other browsers? the other way around...
Never, ever trust IE to do anything right. Always, always use any other more modern browser to initially test your markup. Then look at IE to see if/when it screws things up. In this case, you are probably seeing IE screwing up on margin collapse. Using your original markup, add 'border:1px solid' to the divs just to see if the problem goes away. If it does, then you are seeing an IE bug.
i tried it. It works. Firefox has the same result like IE (like the picture)... I don't understand, why IE has the bug. I would say, that FireFox has a bug. But im new in webdesign and css....
Firefox is performing correctly. When there is a question of which is right. Always go with Firefox, or Opera, or Safari or Chrome. IE rarely does anything correctly. It's 11 years behind all other browsers in modern standards and practices and should be put to sleep. The problem lies in margin collapse which IE is doing incorrectly, as always. Adding the borders forces Firefox to not collapse the margins but I'm too tired to explain it all right now.