开发者

div width ignored in IE 8.0

My doc type is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

I have a div on the page like this:

<div style="width:400px;">
<p>Some content and some more content etc.</p>
</div>

When viewing this in IE 8.0 the div width is ignored and the div occupies not just the whole screen bu开发者_C百科t, if the text between paragraph tags is long enough, goes way off the screen to the right.

So, IE 8.0 completely ignores the width set for the div? How do you get over this please.


I'm not sure if the IE8 issue is that some other (generic?) CSS is overriding yours, but if so, you can try adding the important! modifier like this:

<div style="width: 400px !important;">
<p>Some content and some more content etc.</p>
</div>

Also, if you are overriding the wrapping default somewhere, adding this CSS will restore it to the default:

white-space: normal !important;

The issue may also be with the <p> tag rather than the div, so try using IE Developer tools to track down which element actually has the unnecessarily large width.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜