开发者

br clear="all" vs css solution

I have a div that is float:left, and after the div is the rest of the page. In order to keep the rest of the page below the div, I must first place a

<br cle开发者_运维百科ar="all">

Q: How do I position the rest of the page below the floated div? I think that I need to wrap the rest of the page in a new div and float it as well. But I tend to stay away from floats as much as I can.


after the div you've floated. add the following code.

<div style='clear:both'></div>

then continue the rest of the page as usual.


On the next item you can use the style clear:left.

Another alternative is to set the overflow style on the parent of the floating element to make it contain it, like overflow:hidden.


Create a class and insert into CSS:

br.cb { clear: both; }

Insert into HTML:

<br class="cb">

This made it past W3 markup and CSS validator.


I usually wrap another div around the floating div, with style overflow: auto

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜