开发者

How to align a paragraph to center of cell in table

开发者 https://www.devze.com 2023-03-24 15:57 出处:网络
I want the paragraph in the second row to be aligned to center of table. How can I do that? Full HTML & CSS code in this link

I want the paragraph in the second row to be aligned to center of table. How can I do that?

Full HTML & CSS code in this link

CSS:

table {
    width:100%;
}
table, td {
    border-collapse:collapse;
 开发者_C百科   border:1px solid black;
    padding:0px 5px 10px;
}
.separate {
    text-align:center;
}
.separate p{
    border:1px solid lightgray;
    width:50%;
}

table:

<table>
    <tr>
        <td>AAA</td>
        <td>BBB</td>
        <td>CCC</td>
    </tr>    
    <tr>
        <td colspan="3" class="separate" >
            <p>paragrap</p>
        </td>
    </tr>
</table>


Give the p left and right margin auto margins.

.separate p{
    border:1px solid lightgray;
    margin:0 auto;
    width:50%;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消