Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何清除浮动的img(侧边栏也浮动)_Html_Css_Css Float - Fatal编程技术网

Html 如何清除浮动的img(侧边栏也浮动)

Html 如何清除浮动的img(侧边栏也浮动),html,css,css-float,Html,Css,Css Float,我需要你的帮助 如果可能的话,我想清除最近的浮动块 看起来若页面上有一些浮动块,若我在任何地方使用clear,浮动块将被清除,即使它被放置在另一个div中 html <nav> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li&

我需要你的帮助

如果可能的话,我想清除最近的浮动块

看起来若页面上有一些浮动块,若我在任何地方使用clear,浮动块将被清除,即使它被放置在另一个div中

html

<nav>
    <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
        <li>Item 5</li>
        <li>Item 6</li>
        <li>Item 7</li>
        <li>Item 8</li>
        <li>Item 9</li>
    </ul>
</nav>

<div id="content">
    <img src="http://www.lazne-belohrad.cz/soubory/tinymce/!titulni_obrazky/knihy.png">
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque sapien. In rutrum. Integer in sapien. Nam quis nulla. Aliquam ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.</p>
        <p id="INeedThisUnderImg">This "cleared:left" paragraph clears "nav floated left". Is any way to clear only floated img?  I would like this paragraph under img. I could user position absolute for nav, but if content is only few words, nav overflows footer :(</p>
</div>

    <footer>
        <p>Footer</p>    
    </footer>  

感谢您并为我的英语感到抱歉。

一种解决方案是从该元素中删除
清除:左

div#content p#INeedThisUnderImg {
    clear: left;/*Remove this*/
}
并将
clear:left
添加到此元素
#content
之后的html中:

<br style="clear:left;" />
<br style="clear:left;" />
并在
#content
中最后一个
之后的html中添加
clear:left

<br style="clear:left;" />
<br style="clear:left;" />

也可以在本文中查看