0

divがfloat: leftあり、その後にフロートをクリアしたい。<div style="clear:both;"></div>フローティング div の直後に挿入すると、正常に動作します。問題は、追加のない解決策が必要だということですdiv

タグに追加clear:bothしましたh2が、動作しますが、h2 上部マージンは考慮されません。

HTML:

<p class="with_arrow_down">IF you don’t know the cost you are&nbsp;probably making the wrong decisions</p>
<!--<div style="clear:both;"></div>-->

<h2 class="bigmargin">Check list for maintaining the highest levels </h2>

CSS:

.with_arrow_down {        
    padding-top: 44px;
    height: 30px;
    width: 28%;
    text-align: center;
    margin-left: 5%;
    float: left;
}
.with_arrow_down:nth-of-type + * {
    clear: both;
}
h2.bigmargin {
    margin: 65px 0 65px 0;
    clear:both;
}

h2マージンを機能させる方法を教えてください。

JSFIddle: http://jsfiddle.net/smdgg/3/

4

1 に答える 1

2

それは機能します。

あなたの JS Fiddle デモにはclear: both、質問にある h2 のルールがありません。

それを更新すると、唯一の問題は、その要素の高さが固定されているため、以前のコンテンツと重なることで、コンテンツがオーバーフローします。これは、 overflow hidden を設定することで実証できます。

于 2013-07-20T16:53:33.017 に答える