开发者

How to limit div width?

开发者 https://www.devze.com 2023-04-10 03:15 出处:网络
I have a div inside a table that is overflowing the screen size. It looks like this: <table id=\"hlavni\" style=\" position:absolute; border:none; position:relative; background-color:#FFC; border

I have a div inside a table that is overflowing the screen size. It looks like this:

<table id="hlavni" style=" position:absolute; border:none; position:relative; background-color:#FFC; border:#999 1开发者_如何学Cpx solid;" cellpadding="5">
    <tr>
        <td id="yamana" class="trida" valign="top" style="line-height:1.5em;">
            <div style="background-color:#FFC;" id=load_tweets>44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444</div>
        </td>
    </tr>
</table>

How can I prevent it from overflowing?


<html>
<head>
    <style type="text/css">
    #limit {
        max-width: 500px;
    }
    </style>
</head>
<body>
    <div id="limit">Your content goes here</div>
</body>
</html>


max-width and width -both- do not prevent the overflow if the text does not contain any spaces as in the example in the question.

div {
    max-width : 300px;
    word-wrap: break-word;
}

see this fiddle for a solution.

For this case, the div must have the style "word-wrap: break-word" in order to work.

Or "overflow-wrap: break-word"


With max-width . Example : http://jsfiddle.net/YCV8H/

0

精彩评论

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

关注公众号