我有1个父表格单元格.t
和2个子展示区.ch1
和.ch2
:
HTML:
<div class="t">
<div class="ch1">1</div>
<div class="ch2">2</div>
</div>
CSS:
.t {
display: table-cell;
background-color:green;
height:200px;
width:200px;
}
.ch1 {
background-color:blue;
display: block;
}
.ch2 {
background-color:red;
display: block;
}
是否可以将.ch2
推到底部,但将.ch1
保留在最前面(如果vertical-align: bottom;
使用.t
它会将两个块推到底部)
的jsfiddle: https://jsfiddle.net/hvz4cn69/
答案 0 :(得分:2)
Flexbox可以做到这一点:
.t {
display: flex;
flex-direction: column;
background-color: green;
height: 200px;
width: 200px;
justify-content: space-between;
}
.ch1 {
background-color: blue;
display: block;
}
.ch2 {
background-color: red;
display: block;
}
&#13;
<div class="t">
<div class="ch1">1</div>
<div class="ch2">2</div>
</div>
&#13;
或者
.t {
display: flex;
flex-direction: column;
background-color: green;
height: 200px;
width: 200px;
}
.ch1 {
background-color: blue;
display: block;
}
.ch2 {
background-color: red;
display: block;
margin-top: auto;
}
&#13;
<div class="t">
<div class="ch1">1</div>
<div class="ch2">2</div>
</div>
&#13;
答案 1 :(得分:-1)
您可以将margin-top: 164px;
用于ch2