How to limit div width?
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/
精彩评论