Quantcast Canh giữa table nằm trong thẻ DIV

Canh giữa table nằm trong thẻ DIV

by Neon Quach 2. January 2010 05:40

Nếu bạn muốn canh giữa table mà nằm trong thẻ div thì đây là giải pháp.

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>How to Center a Table inside a Div using CSS</title>

    <style type="text/css">

        #divOne

        {

            width: 400px;

            text-align: center;

            border: dotted 1px black;

        }

        #tblOne

        {

            width: 200px;

            margin: 0 auto;

            border: solid 1px black;

        }

    </style>

</head>

<body>

    <div id="divOne">

        <table id="tblOne">

            <tr>

                <td>

                    R1C1

                </td>

                <td>

                    R1C2

                </td>

                <td>

                    R1C3

                </td>

            </tr>

            <tr>

                <td>

                    R2C1

                </td>

                <td>

                    R2C2

                </td>

                <td>

                    R2C3

                </td>

            </tr>

        </table>

    </div>

</body>

</html>

 
Việc mà set margin = 0  mới là cách và nó hầu như work trên mọi trình duyệt, chúng ta see out put.




Reference : How to Center a Table inside a Div using CSS

Tags: ,


Categories: asp.net | css

blog comments powered by Disqus

About me

I'm  currently employed as Software developer at devinition.com and also a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified Professional Developer (MCPD) in Net Framework 2.0 and 3.5: Web Applications and MCTS .NET Framework 3.5, ADO.NET Applications

Powered by BlogEngine.NET 2.5.0.5 - Eco Theme by n3o Web Designers