我想在我的 div 中将文本排到图像的顶部。
当前标题:网络研讨会、博客等位于方 block 顶部下方。我在那里有一个样式:vertical-align: top;但它没有与正方形的顶部对齐。
查看我的 fiddle - http://jsfiddle.net/huskydawgs/e9pZr/ HTML
<div id="wrapper-resources">
<div id="resources_row">
<div class="resources_cell1">
<div class="resources_lt">
<img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
<div class="resources_rt">
<p><strong>Webinar</strong></p>
</div>
</div>
<div class="resources_cell2">
<div class="resources_lt">
<img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
<div class="resources_rt">
<p><strong>Article</strong></p>
</div>
</div>
<div class="resources_cell3">
<div class="resources_lt">
<img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
<div class="resources_rt">
<p><strong>Blog</strong></p>
</div>
</div>
<div class="resources_cell4">
<div class="resources_lt">
<img height="76" src="https://cdn1.iconfinder.com/data/icons/softwaredemo/PNG/256x256/Box_Red.png" width="76" /></div>
<div class="resources_rt">
<p><strong>Market</strong></p>
</div>
</div>
</div>
</div>
CSS
#wrapper-resources {
position:relative;
width:100%;
border: none;
margin: 50px 0 0 0;
#resources_row {
height:100%;
white-space:nowrap;
}
.resources_cell1, .resources_cell2, .resources_cell3, .resources_cell4 {
height:100%;
width:25%;
display:inline-block;
white-space:normal;
}
.resources_lt {
height:100%;
width:33%;
display:inline-block;
white-space:normal;
margin-right: 20px;
vertical-align: top;
}
.resources_rt {
height:100%;
width:50%;
display:inline-block;
white-space:normal;
vertical-align: top;
}
/* Fonts */
#wrapper-resources p {
color: #666666;
font-family: 'SegoeRegular', Helvetica, Arial, sans-serif;
font-size: .9em;
line-height: 1.6em;
最佳答案
您需要将 <p>
的 margin 重置为 0 http://jsfiddle.net/e9pZr/3/
它默认有margin:1em 0;
见http://reference.sitepoint.com/css/collapsingmargins以获得更多解释。
关于css - 在 div 中将文本排到图像顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21003244/