开发者

content outgrows div 100%

I'm currently trying to make a div that is 100% as wide as the whole screen. And I did it by writing the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
    <title>100% width</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <style type="text/css">
        html,body {
            padding:0px;
            margin:0px;
            width:100%;
        }
    </style>

</head>

<body>

    <div style="background-color:yellow;">
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    </div>开发者_如何学Python;

</body>

</html>

It works fine in normal zoom settings but when I do max zoom in (FireFox 6.0.2) the letters inside the div outgrows the yellow box. Is there a way for the yellow box to extend to the end of the window as well?

Thanks.


You can force the really long word to wrap with:

 word-wrap: break-word;

in your div style.

Does it really matter what happens at maximum zoom though?


Option 1 If you want to keep the text within the yellow box try adding this CSS styling.

div {word-wrap: break-word;}

It will cause the text to go to the next line rather than continue.

Option 2 OR you could try hiding the content that goes past the div border using CSS styling

div {overflow:hidden;}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜