所有文本都显示在 div 之间的顶部
我想在box-left
divs上方的Akita INU和Cockapoo标签中,而是大多数标签都堆叠在Divs之间的中间。我试图将两个Divs放在一个Div中,但它不起作用。
.box-left {
clear: all;
float: left;
border: 1px solid black;
width: 600px;
height: 250px;
margin-top: 15px;
margin-bottom: 15px;
}
.box-right {
float: right;
border: 1px solid black;
width: 600px;
height: 250px;
margin-top: 15px;
margin-bottom: 15px;
}
<div class="label">Akita Inu</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Cockapoo</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Corgi</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Shiba Inu</div>
<div class="box-left"></div>
<div class="box-right"></div>
I want to make the Akita Inu and Cockapoo labels just above box-left
divs but instead most of the labels just stacked in the middle between divs. I tried to put two divs in one div like but it didn't work.
.box-left {
clear: all;
float: left;
border: 1px solid black;
width: 600px;
height: 250px;
margin-top: 15px;
margin-bottom: 15px;
}
.box-right {
float: right;
border: 1px solid black;
width: 600px;
height: 250px;
margin-top: 15px;
margin-bottom: 15px;
}
<div class="label">Akita Inu</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Cockapoo</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Corgi</div>
<div class="box-left"></div>
<div class="box-right"></div>
<div class="label">Shiba Inu</div>
<div class="box-left"></div>
<div class="box-right"></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果我了解您将要做什么,我认为它将与风格变化非常有效。
If I understand what you're about to do, I think it will work very well with the style change.
不要使用浮子。它们是一种过时且麻烦的技术。相反,使用内联容器或 flexbox 。
Don't use floats. They're an outdated and troublesome technique. Instead, use inline-block containers or flexbox.
为此使用Flex。通常应该避免浮子和绝对。
Use flex for this. Floats and absolutes should generally be avoided.
添加
clear:
to.box-left
将其放在上面的浮动项目下方。要将标签放在上方的Divs下方,请将其应用于.label
Add
clear: both
to.box-left
to put it below the floated item above it. And to put the labels below the divs above them, apply the same to.label