div内容不受div宽度限制

发布于 2024-09-16 00:14:12 字数 964 浏览 4 评论 0原文

我可以发誓我看过有关这个问题的文章,但我一辈子都找不到它们! 基本上,如果我

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷你仙 2024-09-23 00:14:12

如果您想隐藏任何溢出的内容,请使用 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;

舂唻埖巳落 2024-09-23 00:14:12

仅在块元素上设置宽度不会阻止任何比该宽度更宽的内容溢出元素的边界。为此,您还需要设置“溢出”属性。将其设置为“隐藏”将简单地隐藏边界之外的任何内容,但您也可以将其设置为其他值以自动显示滚动条等。

请参阅 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.

栀子花开つ 2024-09-23 00:14:12

隐藏你的溢出。

或者更准确地说

.myclass { overflow: hidden; }

Hide your overflow.

Or more precisely

.myclass { overflow: hidden; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文