我使用显示表作为我网站的3列部分。我这样做,因为我需要垂直居中第一列的内容。
如何在保持文本左对齐的同时将第三列向右移动?
<span class="cont">
<span class="one">One</span>
<span class="two">One</span>
<span class="three">
<div class="a">Some text and A</div>
<div class="b">Some more text and B</div>
</span>
</span>
.cont {
display: table;
border: 1px solid black;
width: 100%;
}
.one,
.two,
.three {
display: table-cell;
}
.one {
background: grey;
vertical-align: middle;
}
.two {
background: green;
}
答案 0 :(得分:3)
一个简单的解决方案是使用float: right
到.three
课程和vertical-align: top
到.two
课程:
.cont {
display: table;
border: 1px solid black;
width: 100%;
}
.one,
.two,
.three {
display: table-cell;
}
.one {
background: grey;
vertical-align: middle;
}
.two {
background: green;
vertical-align: top;
}
.three {
float: right;
}
<span class="cont">
<span class="one">One</span>
<span class="two">One</span>
<span class="three">
<div class="a">Some text and A</div>
<div class="b">Some more text and B</div>
</span>
</span>
答案 1 :(得分:3)
答案 2 :(得分:0)
<span class="cont">
<span class="one">One</span>
<span class="two">One</span>
<span class="three">
<div class="set">
<div class="a">Some text and A</div>
<div class="b">Some more text and B</div>
</div>
</span>
</span>
.set{ float:right;}
答案 3 :(得分:0)
答案 4 :(得分:0)
.table { display: table; margin-left: auto;}