JS fiddle :http://jsfiddle.net/nick55555/7tfca64y/
我的情况可能很容易解决,但不知道如何解决。我有一个简单的 div
,里面有一些文本,垂直居中,但是当我将图像插入同一个 div
时,文本现在比原来低起初。如何使文本与插入图像之前的垂直高度相同?图像完全垂直对齐,但文本不是...
#header_Bi {
height: 39px;
width: 748px;
margin: 0;
float: left;
border-left: 1px solid #191919;
border-right: 1px solid #191919;
border-bottom: 1px solid #191919;
font-family: arial, verdana, helvetica, sans-serif;
font-size: 15px;
color: #fff;
font-weight: 100;
text-transform: uppercase;
background: #2c2c2c;
text-align: center;
}
#header_Bi1 {
height: auto;
width: auto;
margin-top: 10px;
}
<div id="header_Bi">
<div id="header_Bi1">
<img src="../images/youtube_tiny.jpg" width="20" height="20" alt="youtube_tiny">
<img src="../images/twitter_tiny.jpg" width="20" height="20" alt="twitter_tiny">
<img src="../images/facebook_tiny.jpg" width="20" height="20" alt="facebook_tiny">
<img src="../images/google_plus_tiny.jpg" width="20" height="20" alt="google_plus_tiny">SALES & ADVICE EMAIL HERE</div>
</div>
最佳答案
如果你想在中间对齐文本和图像,添加 #header_Bi1 img { vertical-align:middle;}
到你的 css
关于html - 插入图片后文本被下推 - 需要垂直对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27706427/