-3

私のサイトには広告付きのテーブルが2つあります。

上の方は中央に配置されているように見えますが、下の方は中央に配置されていません。

テーブルを中央に配置するためにたくさんのコードを追加しようとしましたが、機能していないようです。

現在のコードは次のようになります。

<div align="center">
<table align="center" style="text-align:center; margin-left: auto; margin-right: auto; border-collapse:separate; border-spacing: 20px 0px;">
<tr style="height:100px">
<td><span id="ad1"></span></td>
<td><span id="ad5"></span></td>
<td><span id="ad4"></span></td>
</tr>
</table>
</div>

正しく中央に配置するにはどうすればよいですか?

ありがとう!

4

1 に答える 1

0

テーブル+画像は、それを含むdivよりも幅が広いため、中央に表示されません。以下に示すように、正しく見えるようにいくつかのインラインスタイルを追加しましたが、実際には、コンテナーの幅のサイズを変更するか、使用しているコンテナーに適合する画像を使用する必要があります。

基本的に、テーブルとテーブル内の画像にmax-width:100%を追加しました。

<div align="center" style=" text-align: center;">
    <table align="center" style="text-align:center; margin-left: auto; margin-right: auto; border-collapse:separate; border-spacing: 20px 0px; max-width:100%">
        <tbody>
            <tr style="height:100px">
                <td>
                    <span id="ad1">
                        <a href="http://ltm.me/ad1" title="Amp Cellular" target="_blank">
                            <img src="http://jewishmusicstream.com/ads/amp.jpg" width="300" height="100" style="max-width: 100%;">
                        </a>
                    </span>
                </td>
                <td>
                    <span id="ad5">
                        <a href="http://ltm.me/ad5" title="Get Peyd" target="_blank">
                            <img src="http://jewishmusicstream.com/ads/getpeyd.gif" width="300" height="100" style="max-width: 100%;">
                        </a>
                    </span>
                </td>
                <td>
                    <span id="ad4">
                        <a href="http://ltm.me/ad4" title="The Kosher Chocolatier" target="_blank">
                            <img src="http://jewishmusicstream.com/ads/thekosherchocolatier.png" width="300" height="100" style="max-width: 100%;">
                        </a>
                    </span>
                </td>
            </tr>
        </tbody>
    </table>
</div>
于 2013-02-15T20:05:12.200 に答える