6

表の見出しでは、thタグのデフォルトのテキスト配置は中央です。

次のコードを検討してください。

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
            body {
                background-color: aliceblue;
            }
            .default_grid {
                text-align: left;
                width: 600px;
                color: white;
            }
                .default_grid th {
                    /*  text-align: left;  */
                }
                .default_grid .first {
                    background-color: purple;
                }
                .default_grid .second {
                    background-color: orange;
                }
        </style>
    </head>
    <body>
        <table class="default_grid">
            <thead>
                <tr>
                    <th class="first">Test One</th>
                    <th class="second">Test Two</th>
                </tr>
            </thead>
        </table>
    </body>
</html>

Firefox、Internet Explorer 7 (およびそれ以前)、Safari、Chrome、およびOperaでは、<th> 内のテキストは左揃えになります。Internet Explorer 8およびInternet Explorer 9では、規則が <th> タグで直接指定されていない限り (行番号 14 のコメントを解除)、テキストは中央揃えになります。

正しい動作はどれですか?

4

2 に答える 2

18
于 2012-07-04T02:32:47.487 に答える