看看这个 fiddle 在哪里 it is tried to wrap text in the yellow div without setting its width or the outer divs width - only by using the width of the inner div
我可以做些什么来实现这一点?
非常感谢
最佳答案
虽然为什么不将 #h
的宽度设置为 100 没有任何意义,但您可以尝试这样做:
#a{
background-color: grey;
padding:5px;
display: table;
}
#b{
width: 100px !important;
background-color: orange;
line-height: 15px;
padding:5px;
display: table-cell;
}
#h{
background-color: yellow;
line-height: 15px;
padding:5px;
display: table-row;
}
如果您告诉我们您为什么不想明确定义 #h
的宽度,我认为我们可以为您提供更多帮助,但无论如何我希望这对您有所帮助。
关于CSS:如何在奇怪的情况下强制自动换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12113150/