【发布时间】:2017-07-31 21:06:25
【问题描述】:
我有一个 div,左边有一个图像,右边有一些信息(一个跨度、一个 h3 和另一个跨度)。我希望图像右侧的第一个跨度位于顶部,h3 位于中心,另一个跨度位于底部。但这不起作用。同样在分隔符 div 的右侧,我有一个我也想定位在底部的链接和一个我想定位在中心的跨度。
你知道问题出在哪里吗?
示例:https://jsfiddle.net/ct1ghpk2/2/
HTML:
<div class="item">
<img src="">
<div class="item_info">
<span class="align-t">Span aligned at top</span>
<h3>Title aligned at center</h3>
<span class="align-b">Span aligned at bottom</span>
</div>
<div class="item_separator"></div>
<div class="item_details">
<span>Span aligned at center</span>
<a href="">Link aligned at bottom</a>
</div>
</div>
CSS:
.item{
background-color:white;
display: flex;
margin-bottom: 20px;
align-items: flex-start;
padding: 10px;
justify-content: space-between;
height: 10em;
border:1px solid red;
}
.item img{
width: 20%;
height: 100%;
}
.item_info{
margin-left: 10px;
flex-basis: 64%;
display:flex;
flex-direction:column;
}
.item_info .align-t{
color:gray;
font-size: 0.8em;
margin-bottom: 20px;
}
.item_info h3{
font-size: 1em;
text-align: justify;
margin-bottom: 20px;
}
.item-info .align-b{
}
.item_separator{
height:100%;
width:1px;
background-color:red;
}
.item_details{
flex-basis: 30%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.item_details span{
font-size: 0.85em;
margin-bottom: 10px;
color:gray;
}
.item_details a{
font-size: 0.85em;
padding: 10px;
border-radius: 4px;
width: 100%;
text-align: center;
}
img {
width: 100%;
max-width: 100%;
vertical-align: middle;
margin: 0;
}
【问题讨论】: