问答详情
源自:13-4 起飞咯 - 浮动模型

使用了浮动模型后,如何让下一个元素不浮动?

<head>

<style type="text/css">

            div{float: left;}

        </style>

</head>

 <body>

<div id="div1">

        <pre class="mycode" style=width:300px>

    div{

        width:200px;

        height:200px;

        border:2px solid red;

        <span class="red">float:left;</span>  /* 实现靠左浮动 */

        <span class="red">float:right;</span> /* 实现靠右浮动 */        

    }

    &lt;div id="div1"&gt;&lt;/div&gt;

    &lt;div id="div2"&gt;&lt;/div&gt;

        </pre>

        </div>

        <div id="div2"><img src="../img/浮动模型左靠.jpg" width="300px"></div>

        <div style="float: none"></div>

        <br />

        <h3>7.1.3 层模型</h3>

        <p>层模型就像Photoshop的图层精准定位一样,分为三种形式:</p>

        <ol>

            <li><strong>绝对定位</strong>(positioning:absolute)</li>

            <li><strong>相对定位</strong>(positioning:relative)</li>

            <li><strong>固定定位</strong>(positioning:fixed)</li>

        </ol>

</body>

我实现了两块div的并行浮动,但是后面的文本和序列继续并列在div之后了,并不是另起一行,怎么回事呀?

http://img1.mukewang.com/5d7ddb450001481210690446.jpg

提问者:IEwuIL7 2019-09-15 14:33

个回答

  • qq_慕用4405909
    2019-12-09 14:48:29

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

  • GoupDeGrace
    2019-09-16 09:08:06

    maybe you can try again