div内容不受div宽度限制
我可以发誓我看过有关这个问题的文章,但我一辈子都找不到它们! 基本上,如果我
<div style="width: 250px;">The width of this div should be no less than 250px wide</div>
在下面的代码中, div
中的内容不会将其宽度限制为指定的宽度,从而导致溢出问题:
<div class="PostIt">
<div id="tags"><span class="qExtraLarge"><a href="Team/Default.aspx#lucky">Lucky Khumalo</a></span>
<span class="qLarge"><a href="Investments/Social/School/Default.aspx">School</a></span>
a;orghaepoht8aegae[hgi'aehg[ahgiha[e8gjaerghuoaeir'ghu;dsOsgh;vrwi/jbvh?URbnIRWhb'a[985h[qygherionhbdl</div>
</div>
.PostIt { display: block; text-align: left; padding: 30px 30px 30px 30px; height: 240px !important; width: 190px !important; background: transparent url("Images/PostIt.png"); }
.PostIf #tags { width: 250px !important; }
任何建议都会很棒!
提前致谢。
I could swear I've seen articles about this problem, but I can't for the life of me find them again!
Basically if I have
<div style="width: 250px;">The width of this div should be no less than 250px wide</div>
In the code below, the content in the div
isn't restricting it's width to the width specified causing an overflow problem:
<div class="PostIt">
<div id="tags"><span class="qExtraLarge"><a href="Team/Default.aspx#lucky">Lucky Khumalo</a></span>
<span class="qLarge"><a href="Investments/Social/School/Default.aspx">School</a></span>
a;orghaepoht8aegae[hgi'aehg[ahgiha[e8gjaerghuoaeir'ghu;dsOsgh;vrwi/jbvh?URbnIRWhb'a[985h[qygherionhbdl</div>
</div>
.PostIt { display: block; text-align: left; padding: 30px 30px 30px 30px; height: 240px !important; width: 190px !important; background: transparent url("Images/PostIt.png"); }
.PostIf #tags { width: 250px !important; }
Any suggestions would be great!
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想隐藏任何溢出的内容,请使用
overflow:hidden;
如果您想显示内容并仅强制换行,请使用
word-wrap:break-word;
>If you want to hide any overflowing content, use
overflow:hidden;
If you want to show the content and just force a line break, use
word-wrap:break-word;
仅在块元素上设置宽度不会阻止任何比该宽度更宽的内容溢出元素的边界。为此,您还需要设置“溢出”属性。将其设置为“隐藏”将简单地隐藏边界之外的任何内容,但您也可以将其设置为其他值以自动显示滚动条等。
请参阅 http://reference.sitepoint.com/css/overflow 有关溢出 CSS 属性的详细解释。
Setting a width on a block element alone won't stop any contents that are wider than that width from overflowing the bounds of the element. To do that you need to also set the "overflow" property. Setting it to "hidden" will simply hide anything outside the bounds, but you can also set it to other values to automatically show scrollbars, etc.
See http://reference.sitepoint.com/css/overflow for a good explanation of the overflow CSS property.
隐藏你的溢出。
或者更准确地说
Hide your overflow.
Or more precisely