garry27 Posted July 6, 2011 Share Posted July 6, 2011 This problem really annoys me... Why is it when you float a block element, the block element that follows has to float (possibly in the same direction only) in order for it's top margin to register? It doesn't matter if you set the top margin to 100000em and set clear both the second element just won't shift unless you float it. Adding an intermediary block to clear the float doesn't help either. e.g. <div style="background-color:#00C ; float:left; width:200px; height:100px;"/></div> <div style="background-color:#00C ; clear:left; margin: 10000000px 0 0 40px; width:200px; height:100px;"/></div> Quote Link to comment https://forums.phpfreaks.com/topic/241179-clear-float-problem/ Share on other sites More sharing options...
cssfreakie Posted July 6, 2011 Share Posted July 6, 2011 you might want to have a read in the css manual on the property float. this is exactly what it (float) is suppose to do in your code given(also see this). Run the code below and see what i mean. (notice the word moo) mooo<div style="background-color:#00C ; float:left; width:200px; height:100px;"></div> <div style="background-color:#00C ; clear:left; margin: 200px 0 0 40px; width:200px; height:100px;"></div> or try <div style="background-color:green; overflow:hidden;"> <div style="background-color:#00C ; float:left; width:200px; height:100px;"></div> <div style="background-color:#00C ; clear:left; margin: 200px 0 0 40px; width:200px; height:100px;"></div> </div> Just another thing. your markup was invalid this didn't cause your problem, but it still is invalid to do the following: <div/></div> see your code (<div style="background-color:#00C ; float:left; width:200px; height:100px;"/></div>) Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/241179-clear-float-problem/#findComment-1238857 Share on other sites More sharing options...
garry27 Posted July 6, 2011 Author Share Posted July 6, 2011 you might want to have a read in the css manual on the property float. this is exactly what it (float) is suppose to do in your code given(also see this). Run the code below and see what i mean. (notice the word moo) mooo<div style="background-color:#00C ; float:left; width:200px; height:100px;"></div> <div style="background-color:#00C ; clear:left; margin: 200px 0 0 40px; width:200px; height:100px;"></div> or try <div style="background-color:green; overflow:hidden;"> <div style="background-color:#00C ; float:left; width:200px; height:100px;"></div> <div style="background-color:#00C ; clear:left; margin: 200px 0 0 40px; width:200px; height:100px;"></div> </div> Just another thing. your markup was invalid this didn't cause your problem, but it still is invalid to do the following: <div/></div> see your code (<div style="background-color:#00C ; float:left; width:200px; height:100px;"/></div>) Hope this helps. I've read the links you posted but I'm still confused. Would you mind clarifying please how I can fix the problem Quote Link to comment https://forums.phpfreaks.com/topic/241179-clear-float-problem/#findComment-1238950 Share on other sites More sharing options...
cssfreakie Posted July 6, 2011 Share Posted July 6, 2011 the code above fixed the problem... I could clarify, but there are enough resources out there already that do. http://www.positioniseverything.net/easyclearing.html Quote Link to comment https://forums.phpfreaks.com/topic/241179-clear-float-problem/#findComment-1239083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.