根据红色DIV的高度垂直对齐我的列表项(原因1,原因2等)的最佳方法是什么(红色DIV的高度由大文本的大小驱动左)没有给DIV固定的高度?我尝试了display:inline-block
+ vertical-align:middle
,但没有成功http://jsfiddle.net/ggfcN/1/
HTML
<div class="wrapper">
<div class="block-left bigtext">Pouquoi<br>faire appel<br> à nos services?</div>
<div class="block-right"><ul class="bullets1-alt">
<li><i class="fa fa-check"></i> Reason 1</li>
<li><i class="fa fa-check"></i> Reason 2</li>
<li><i class="fa fa-check"></i> Reason 3</li>
</ul>
</div>
</div>
CSS:
.bullets1-alt li {
margin-bottom: 3px;
margin-left: 30px;
padding: 0px;
color: #333;
list-style-type: none;
font-weight: 300;
font-size: 14px;
}
.bigtext {
color: #124191;
font-weight: 600;
font-size: 53px;
text-align: right;
line-height: 53px;
padding-top: 30px;
padding-bottom: 30px;
}
.wrapper {
position: relative;
display: block;
margin-right: auto;
margin-left: auto;
width: 980px;
overflow: hidden;
background: red;
}
.block-left {
float: left;
box-sizing: border-box;
padding-right: 20px;
width: 50%;
}
.block-right {
float: right;
overflow: hidden;
box-sizing: border-box;
width: 50%;
}
答案 0 :(得分:1)
写:
.block-left, .block-right {
display:table-cell;
vertical-align:middle;
padding:30px 0;
height:100%;
}
.wrapper {
display:table;
}
从float:right
移除.block-right
,从float:left
移除.block-left
答案 1 :(得分:1)
您可以使用内联块,但首先需要删除浮动
<div class="wrapper">
<div class="block block-left bigtext">
Pouquoi<br>faire appel<br> à nos services?
</div><div class="block block-right"><ul class="bullets1-alt">
<li><i class="fa fa-check"></i> Reason 1</li>
<li><i class="fa fa-check"></i> Reason 2</li>
<li><i class="fa fa-check"></i> Reason 3</li>
</ul>
</div>
</div>
.bullets1-alt li {
margin-bottom: 3px;
margin-left: 30px;
padding: 0px;
color: #333;
list-style-type: none;
font-weight: 300;
font-size: 14px;
}
.bigtext {
color: #124191;
font-weight: 600;
font-size: 53px;
text-align: right;
line-height: 53px;
padding-top: 30px;
padding-bottom: 30px;
}
.wrapper {
position: relative;
display: block;
margin-right: auto;
margin-left: auto;
width: 980px;
overflow: hidden;
background: red;
}
.block {
vertical-align: middle;
display: inline-block;
overflow: hidden;
box-sizing: border-box;
width: 50%;
}
答案 2 :(得分:0)
使用box-sizing时,某些浏览器仍然需要供应商前缀:
.block-left {
float: left;
-moz-box-sizing:border-box;
box-sizing: border-box;
padding-right: 20px;
width: 50%;
}