我尝试使用border-bottom
向h1
添加一行,但h1
赢了中心。另一次尝试是text-decoration: underline
,但没有任何改变。对于居中,我尝试在table
,tr
,td
上使用它。我试图在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>
答案 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;
}