【问题标题】:Centering image and text vertically垂直居中图像和文本
【发布时间】:2014-10-30 09:55:11
【问题描述】:

我试图在所有浏览器中垂直居中一些文本,但由于某种特殊原因,我遇到了这种特定情况的问题。请参阅 Fiddle 以获取示例。我希望 Tester 这个词和图像一样垂直居中。感谢您的帮助。

http://jsfiddle.net/56jxjq69/2/

<div id="heading" style="margin: auto; display: block;">
<a href="http://www.sss.com"><img src="images/newlogo200x200.png" style="width: 50px;
height: 50px;
position: absolute;
margin-left: 2.5%;
margin-top: .5%;"/></a>
<div id="header" style="margin: 0 auto;
padding: 5px 0 0 0 !important;
width: 100% !important;
clear: both; 
background-color: black;
color: white;
vertical-align: middle;
height: 70px;">

<span id="headtxt" style="font-family: ethno;
max-height: 80px;
font-size: 50px;
width: 65%;
padding: 0;
display: block;
margin: auto;
line-height: 55px; vertical-align: middle;text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
color: black;">
TESTER</span>

</div></div>

【问题讨论】:

标签: html css text-align


【解决方案1】:

那里有很多东西。我确实删除了一些没有任何视觉影响的东西。我最终得到了:

<div id="heading" style="margin: auto; display: block;">
  <div id="header" style="padding: 5px 0 0 0 !important;width: 100% !important;background-color: black;color: white;vertical-align: middle;height: 70px;">
    <div style="text-align:center;">
      <a href="http://www.sss.com">
        <img src="images/newlogo200x200.png" style="position:relative;top:8px;width: 50px;height: 50px;"/>
      </a>
      <span id="headtxt" style="font-family: ethno;font-size: 50px;text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;color: black;">
        TESTER
      </span>
    </div>
  </div>
</div>

看看fiddle

【讨论】:

    猜你喜欢
    • 2018-05-26
    • 1970-01-01
    • 2014-06-25
    • 2014-03-19
    • 2013-10-15
    • 1970-01-01
    • 2010-12-30
    相关资源
    最近更新 更多