1

I am having problems with nested divs in Chrome and IE, whereas in Firefox it works fine.

I have two style attribute (text-indent and margin-top) set in the outer div. The "display" style of inner div is set to block. So, ideally the content after the inner div should appear in a new line without any indentation. It appears so in Firefox, whereas in Chrome/IE it appears with text indentation! Based on this behaviour if I assume that this content fragment (from "remaining text" shown below) inherits the style attribute of the corresponding div, that is not the case too; because, only the text-indent is inheritted and the margin-top is not! Could you please help me to understand on where I am doing wrong?

By the way here is the html fragment:

<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>

Thanks
Srikanth

4

1 回答 1

0

浏览器可能正在对元素应用默认样式。margin: 0; padding: 0;除了设置您自己的自定义边距外,请尝试显式设置元素。

于 2011-11-10T13:49:50.587 回答