Jump to content

clear single float


jcombs_31

Recommended Posts

I have a left column that is floated left. Then I have an image in teh main body that is floated left so that the text will wrap.  I need to clear the image float, and not the left column float.  How can this be done?  If I clear left for my next element, it clears the entire left column which is not what I want.
Link to comment
https://forums.phpfreaks.com/topic/25962-clear-single-float/
Share on other sites

I hope I am not insulting you with this solution, but one way to accomplish what I think you are after is to display your text as a block element. Try this. . .

[b]CSS[/b]
#left{float:left;}
#img{float:left;}
#text{display:block;}

[b]HTML[/b]
<div id="left">

</div>

<div id="main">
    <img src="images/cart_sm.png" />
    <div id="text">Hello, this is some text. Hope it works.</div>
</div>
</body>

If you don't want to introduce another division, use <p></p> around your text since paragraphs are block elements be default.

RyanOD
Link to comment
https://forums.phpfreaks.com/topic/25962-clear-single-float/#findComment-119511
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.