link text sticks out of the div
to开发者_开发技巧 make it simple, i've got following code:
<div>
<a>view all your links</a>
</div>
the width of the div is very small so the text "all your links" sticks out of the div. how do i do to have a new line after "all your" so "links" dont stick out?
If you want to break links visually so they don't extend out of a div, you can add word-wrap: break-word
to a
in your stylesheet. Thus:
a {
word-wrap: break-word;
}
You have not specified your desired result. Do you want the div to resize to accomodate the entire width of the links? If so, don't put a fixed width on it or any of its ancestor elements. Do you want the overlong links to be cut off? If so, put overflow: hidden
in the style of the div.
Use the max-width
property for your a
links.
Edit: You'll likely need a display: block
for your a
tag as well.
Use this code:
a {
word-wrap: break-word;
white-space: normal;
}
精彩评论