开发者

How to vertically and horizontally center a P of text in the page

I want to create a pag开发者_如何学编程e that justs has a paragraph of text centered in the page vertically and horizonally. Any ideas on how? Thanks


Sure, here is how: http://jsfiddle.net/sl1dr/vAdzu/


If you know the paragraph width/height, you may use CSS with this method. I can only think of tables for dynamic content, maybe the CSS experts will have better options.


<table style="width: 100%; height: 100%; border: 0px; padding: 0px; margin: 0px;">
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td style="width: 30%;"></td>
        <td>Test</td>
        <td style="width: 30%;"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

Ajust the widths to your suiting. This is short of using complicated JavaScript.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜