【发布时间】:2014-03-06 07:43:00
【问题描述】:
我有一个包含 2 个 div 的包含 div,一个向左浮动,另一个向右浮动。在两个内部 div 之间,我有一个需要垂直居中的图像。
我已经在网上寻找解决方案,但似乎没有一个对我有用。我在我的代码下面发布。
HTML:
<div id="rt-banner2">
<div id="rt-contact_card">
<h1 class="_site-title">Title</h1>
<h2 class="site-subtitle">SubTitle</h2>
<h2 class="_site-title">Mob: +123 453 769</h2>
<h2 class="_site-title">name.surname@gmail.com</h2>
</div>
<div id="site-header">
<img src="http://mydomain.com/wp-content/themes/themeName/images/stock-photo-dried-rose-buds-tea.jpg" width="531px" height="246px" alt="">
</div>
<span><img id="rt-arrow-div" src="http://mydomain.com/wp-content/themes/themeName/images/arrow.png" alt=""></span>
<div class="rt-clear"/>
</div>
CSS:
#rt-banner2 {
border-top: 25px solid #be2331;
border-bottom: 25px solid #be2331;
height:246px;
width:100%;
text-align: center;
}
#rt-contact_card
{
float:left;
width:431px;
background:teal;
height:100%;
}
#rt-contact_card h1
{
text-align:center;
font-size:1.3em;
}
#rt-contact_card h2
{
text-align:center;
font-size:1.2em;
}
#rt-banner2 span {
display: inline-block;
height: 100%;
vertical-align: middle;
}
#rt-banner2 span img
{
vertical-align: middle;
max-height: 246px;
}
#site-header
{
float:right;
width:531px;
}
.rt-clear
{
clear:both;
}
我将发布结果图片的链接。 http://i57.tinypic.com/16a2zj9.png http://it.tinypic.com/view.php?pic=16a2zj9&s=8#.UvarKrRDFuM
需要垂直居中的图片是中间的箭头。
我做错了什么?有人可以告诉我吗?提前感谢您的宝贵时间。
【问题讨论】: