gpt4 book ai didi

html - div 的 float 内容

转载 作者:太空宇宙 更新时间:2023-11-04 15:15:11 28 4
gpt4 key购买 nike

我有一个固定宽度的 div,我想将它显示在容器的右侧。在左侧,我想显示一个 div,以便其文本在右侧 div 结束后扩展到右侧 div 下方。请看下图:

enter image description here

这是我目前正在尝试的:

HTML:

<div class="wrapper">
<div class="left">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu ipsum augue. </div>
<div class="right">float right.</div>
</div>

CSS:

.wrapper{
overflow: hidden;
border: 1px solid red;
width: 300px;
}

.left{
float: left;
width: 200px;
background: brown;
}

.right{
float: right;
width: 100px;
background: green;
}

JSFiddle: http://jsfiddle.net/qyrKY/

最佳答案

将 div 的顺序更改为以下内容:

<div class="wrapper">
<div class="right">float right.</div>
<div class="left">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu ipsum augue. Nulla ac turpis sem, vitae iaculis diam. Pellentesque nisl magna, gravida tempus laoreet in, bibendum eget dolor. Morbi convallis sem faucibus turpis viverra vestibulum. Nam at urna elit, eget elementum elit. Donec pretium placerat mauris ut blandit. Phasellus sit amet est ante, quis dignissim metus. Mauris id neque ligula, sit amet convallis nunc.</div>
</div>

并将您的左侧 CSS 类更改为:

.left {
background: brown;
}

jsFiddle example

关于html - div 的 float 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16003669/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com