1

Chrome と IE ではネストされた div に問題がありますが、Firefox では問題なく動作します。

外側の div に 2 つのスタイル属性 (text-indent と margin-top) を設定しています。内部divの「表示」スタイルはブロックに設定されています。したがって、理想的には、内側の div の後のコンテンツは、インデントなしで新しい行に表示される必要があります。Firefox ではそのように表示されますが、Chrome/IE ではテキストのインデントが表示されます! この動作に基づいて、このコンテンツフラグメント (以下に示す「残りのテキスト」から) が対応する div のスタイル属性を継承すると仮定すると、そうではありません。なぜなら、text-indent だけが継承され、margin-top は継承されないからです! 私が間違っているところを理解するのを手伝ってもらえますか?

ちなみに、ここにhtmlフラグメントがあります:

<div style="text-indent:50px; margin-top:100px">
Initial text in outer div. More text typed here. Still more text typed here. More and more text typed here. Still more text typed here just to fill the content so that the para wraps to more than one line. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text.

<div style="text-indent:0px;">Text in inner div. More text typed here. Still more text typed here. More and more text typed here. Still more text typed here just to fill the content so that the para wraps to more than one line. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text.</div>

remaining text in outer div. More text typed here. Still more text typed here. More and more text typed here. Still more text typed here just to fill the content so that the para wraps to more than one line. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text. More filler text.
</div>

ありがとう
_

4

1 に答える 1

0

ブラウザーは、おそらくデフォルトのスタイルを要素に適用しています。margin: 0; padding: 0;独自のカスタム マージンを設定するだけでなく、要素に明示的に設定してみてください。

于 2011-11-10T13:49:50.587 に答える