gpt4 book ai didi

html - 无法控制 div 的宽度,如何解决?(html)

转载 作者:太空宇宙 更新时间:2023-11-03 23:08:55 24 4
gpt4 key购买 nike

这是 html 和 CSS 代码:

.d1 {
display: inline-block;
font-size: 16pt;
width: 30px;
border: 3px solid #73AD21;
}
<div class="d1">
testingggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</div>

即使我设置了,文本还是突破了div的宽度

display:inline-block

有没有什么方法可以让文字在div的宽度之内?

最佳答案

将您的 CSS 设置为 word-wrapbreak-word

.d1{
display:inline-block;
font-size:16pt;
width:30px;
border: 3px solid #73AD21;
word-wrap: break-word;
}
<div class="d1">
testingggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</div>

关于html - 无法控制 div 的宽度,如何解决?(html),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33573416/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com