0

IAB ビルボード広告用のサブヘッダー コンテナーがあり、広告を中央に配置する必要があるコンテナーで、2 つの異なる幅の広告を考慮する必要があります。

私の質問は、自動幅を使用して中央揃えの要素に幅を持たせないための回避策はありますか?

私の基本的なコード構造は次のとおりです。

<div class="sub_header_wrap" style="width:970px">
    <div class="ad" id="pencil00" style="margin:0 auto;min-height:30px">
        <!-- some ad code -- may be 970px or 950px wide -->
    </div>
</div>

ここで別の解決策を見つけましたが、使用する前に注意事項を知りたいです。sub_header_wrap私の完全なコードでは、広告の位置以外にもコンテナ内に他の要素があります。このソリューションによって悪影響を受ける可能性があります。

<div class="sub_header_wrap" style="width:970px;text-align:center">
    <div class="ad" id="pencil00" style="text-align:left;display:inline-block;min-height:30px">
        <!-- some ad code -- may be 970px or 950px wide -->
    </div>
</div>

このソリューションは、コンテナ内に計算された 4px の追加の高さを生成するように見えました.sub_header_wrap

4

1 に答える 1

2

解決策は...

<div class="sub_header_wrap" >
    <div class="ad" id="pencil00" style="margin:0 auto;min-height:30px;max-width: 970px;text-align: center;">
        <!-- some ad code -- may be 970px or 950px wide -->
    </div>
</div>

また

<div class="sub_header_wrap" style="width:970px;text-align:center">
    <div class="ad" id="pencil00" style="text-align:left;display:inline-block;min-height:30px; margin-bottom: -4px;">
        <!-- some ad code -- may be 970px or 950px wide -->
    </div>
</div>
于 2012-11-29T04:55:41.530 に答える