我知道答案很简单,它可能是一个小的 CSS 属性,但我试图在不在这里询问的情况下找到解决方案,但运气不佳..
在一个 div 容器中有两个 div 容器,它们玩起来不太好。
一个定位在父div的右上角 float ,它不会让任何其他容器 float 到它的右边。
我尝试了 display:inline
和 display:inline-block
但没有成功...
这是代码,虽然有些东西告诉我答案很简单,你不需要它!:
父级 div、右上角的 div 和试图向右浮动的可怜的 div:
#um-home-section4 {
width:100%;
height:300px;
background-color: green;
}
#um-title-right {
float:right;
width:500px;
height:50px;
margin-right:20px;
margin-top:20px;
background-color: fuchsia;
}
#take-me-there {
float:right;
margin-top:240px;
margin-right:0px;
height:50px;
width:100px;
background-color: gray;
}
<div id="um-home-section4">
<div id="um-title-right"></div>
<div id="take-me-there"></div>
</div>
最佳答案
您只需更改 HTML 中的顺序:
<div id="um-home-section4">
<div id="take-me-there">
</div>
<div id="um-title-right">
</div>
</div>
关于css - 为什么这个 div 容器会阻止另一个 div 容器向右浮动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19886029/