最近の更新

2016年10月31日月曜日

テーブルを左右にぴったり並べる方法

【目的】
テーブルを左右に2つぴったり並べます。



【手順】
1.「index.html」というファイルを作成。
2.「index.html」を以下の様に入力。
<!doctype html>
<html>
    <head>
    </head>
    <body>
        <table style="border-collapse: collapse;">
            <tbody>
                <tr>
                    <td valign="top" style="padding: 0px;">
                        <table border="1">
                            <thead>
                                <tr>
                                    <th>番号</th>
                                    <th>名前</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td>あああああ</td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>いいいいい</td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td>ううううう</td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                    <td valign="top" style="padding: 0px;">
                        <table border="1">
                            <thead>
                                <tr>
                                    <th>項目1</th>
                                    <th>項目2</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>項目1-1</td>
                                    <td>項目2-1</td>
                                </tr>
                                <tr>
                                    <td>項目1-2</td>
                                    <td>項目2-2</td>
                                </tr>
                                <tr>
                                    <td>項目1-3</td>
                                    <td>項目2-3</td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

3.「index.html」をブラウザで開きます。
4.以下の様に表示されれば成功です。














以上です。

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。

関連記事