当我浮动其他 div 元素时,为什么浮动图像移动到 div 内的段落旁边移动 div 之外?
例如,我有一个 div class ,其中有一个段落,当我将图像浮动到该类中时,它会以我想要的方式包裹它?
.container {
margin:0px auto;
width: 1400px;
background-image: url(back.png);
padding-top:10px;
height: 2000px;
}
.main {
background-color: #f7f4f4;
margin-right: 600px;
box-shadow: 10px 10px 10px #705656;
border-radius: 10px;
border: 2px solid red;}
.green {
border: 2px solid blue;
width: 400px;
margin-right: 40px;
background-color: #8bed8f;
float: right;}
.aside {
background-color: #f47575;
width: 400px;
margin-right: 40px;
border-radius: 4px;
float: right;
clear: right;}
.trac input[type=button] {
background-color: #9b878b;
font: weight: bold;
font-size:15px;
color: white;
border-radius: 6px;
border: none;
padding: 20px 10px;
margin-left: 300px;
margin-top: 5px;}
.tmac {
float: left; }
答案 0 :(得分:0)
如果我理解你的问题(你问的问题有点乱),你必须考虑浮动的HTML元素包装到最近的位置相对容器。
如果你想将浮点数粘贴到特定容器,你只需要在该容器的CSS类中添加规则position: relative