线/文本不会居中

时间:2015-08-14 17:48:24

标签: alignment center

我尝试使用border-bottomh1添加一行,但h1赢了中心。另一次尝试是text-decoration: underline,但没有任何改变。对于居中,我尝试在tabletrtd上使用它。我试图在h1下面放一条2px线。我做错了什么?

hr.hrNews {
    background-color: #000000;
    border: 0;
    height: 1px;
    max-width: 236px;
    text-align: center;
    vertical-align: middle;
    width: 100%;
}

<table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align: center; vertical-align: middle;">
    <tr>
        <td style="text-align: center; vertical-align:middle;">
            <h1 style="text-align: center;">In The News</h1>
            <hr class="hrNews" />
        </td>
    </tr>

</table>

UPDATE: This is what I see on Dreamweaver and Wordpress

1 个答案:

答案 0 :(得分:1)

您可以使用text-align容器上的<h1>属性来实现此目的:http://jsbin.com/jujurobebo/edit?html,css,output

#bottom{
  min-width: 500px;
}
#top{
  text-align: center;
}
h1{
  width: 230px;
  border-bottom: 1px solid #000000;
  padding-bottom: 10px;
  display: inline-block; 
  margin-bottom: 25px;
}
#bottom img{
  width: 250px
}
#bottom p{
  width: 250px; 
  margin: 0; 
}
#bottom img, 
#bottom #left{
  display: inline-block;
}