我想将div
放在左下角div
之间。每个宽度必须为40%。我试图在没有Javascript的情况下这样做。
#left_col,#right_col,#bottom {
width: 40%;
height:200px;
float:left;
clear:left;
padding: 0;
border: #0BDC00 solid 2px;
}
#right_col{
float:right;
clear:right;
text-align: right;
display:table-cell;
}
答案 0 :(得分:1)
而不是使用clear:left
和clear:right
代替使用clear:both
;
#left_col,#right_col,#bottom {
width: 40%;
height:200px;
float:left;
clear:both;
padding: 0;
border: #0BDC00 solid 2px;
}
#right_col{
float:right;
clear:both;
text-align: right;
display:table-cell;
}
答案 1 :(得分:0)
*,
*:before,
*:after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #F72F4E;
}
.Container {
width: 600px;
padding: 20px;
border: 1px solid #000;
}
.Row {
display: flex;
}
.Row:nth-of-type(odd) {
justify-content: flex-start;
}
.Row:nth-of-type(even) {
justify-content: flex-end;
}
.Row__item {
width: 40%;
background: #000;
height: 60px;
}
<div class="Container">
<div class="Row">
<div class="Row__item">
</div>
</div>
<div class="Row">
<div class="Row__item">
</div>
</div>
<div class="Row">
<div class="Row__item">
</div>
</div>
</div>