简单的表格单元格文本拒绝居中

时间:2014-03-26 18:36:03

标签: html css html-table text-align

我想要的只是.TableH水平居中。我通常在处理这样的小事情时非常体面,但这让我疯狂。我没有尽可能多地使用桌子如果有人可以帮助我,那就太棒了。

HTML:

    <div id="Contactbody">
    <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6118.82203107468!2d-74.17584896118852!3d39.932195088535714!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x8c86de105986c5c3!2sEaglespeed+Oil+%26+Lube!5e0!3m2!1sen!2sus!4v1395432683622" frameborder="0" style="border:0"></iframe>
    <table>
        <tbody>
            <tr>
                <td class="TableH">Hours</td>
            </tr>
            <tr>
                <td class="Day">Mon</td>
                <td class="Hours">8 - 6</td>
            </tr>
            <tr>
                <td class="Day">Tues</td>
                <td class="Hours">8 - 6</td>
            </tr>
            <tr>
                <td class="Day">Wed</td>
                <td class="Hours">8 - 7</td>
            </tr>
            <tr>
                <td class="Day">Thur</td>
                <td class="Hours">8 - 6</td>
            </tr>
            <tr>
                <td class="Day">Fri</td>
                <td class="Hours">8 - 6</td>
            </tr>
            <tr>
                <td class="Day">Sat</td>
                <td class="Hours">7:30 - 3:30</td>
            </tr>
            <tr>
                <td class="Day">Sun</td>
                <td class="Hours">8:30 - 1</td>
            </tr>
        </tbody>
    </table>
</div>

CSS:

#Contactbody {
position: absolute;
display: none;
margin: 8% 0 0 15%;
width: 70%;
height: auto;
border-left: 4px solid #ffe168;
}

#Contactbody iframe {
    display: block;
    float: left;
    margin-left: 2.5%;
    width: 40%;
    height: auto;
}

#Contactbody table {
    float: right;
    margin-right: 5%;
    width: 25%;
    font-family: Aleygra Sans SC, Maven Pro, Verdana, Arial;
}

.TableH {
color: #0b0658;
vertical-align: middle;
font-weight: bold;
    text-align: center;
}

1 个答案:

答案 0 :(得分:2)

您的单元格只跨越一列,您可能需要:

<td class="TableH" colspan="2">Hours</td>