我只想在这里询问我的html代码,在调整div时我有点问题。当我将div的宽度设置为70px时,内容仍然超过了div,我想要的是,当div的内容超过div的宽度时,div的高度将自动调整。
任何帮助? 继承我的代码。提前谢谢
<div class = "center"> the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the
lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps
over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown
fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the
quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy
dog.the quick brown fox jumps over the lazy dog. </div>
<style> .center{width:70px;} </style>
答案 0 :(得分:2)
试试这个css
.center
{
width:70px;
word-wrap: break-word;
}
强制浏览器破坏否则会使容器生效的单词。
答案 1 :(得分:1)
您描述的所需行为是默认行为(proof) - 如果它不起作用,那么有些样式会干扰这种行为,请尝试消除它们。
另外,请注意<style>
标记需要放在头部,不允许在正文中使用(确切地说 - 它位于HTML5中,属性为scoped
但是atm这在浏览器中支持得非常差)
答案 2 :(得分:0)
将以下属性添加到CSS类
overflow: auto;