我有一个关于 css 样式的问题,我想将 max-height 设置为 outer 。当我只设置高度时它工作正常,但是当我想将它设置为最大高度时,内部的内容消失了。
您可以在此处获取示例:http://sara.hil.ch/grega/example5.html
有什么建议吗?
//outer div style
div.dogodkiinhalt {
position: relative;
top: 0px;
left: 0px;
width: 400px;
padding-bottom: 0px;
background: blue;
border: none;
overflow: auto;
visibility: visible;
height: 200px;
}
//inner div style
#inhaltbox {
position: absolute;
top: 0px;
overflow: hidden;
width: 400px;
height: 200px;
display: none;
display: block;
}
最佳答案
是的,如果您设置 max-height
- 最小高度是多少?零!
您还需要设置min-height
或height
。
此外,这里还有一些问题。
div.dogodkiinhalt {
position: relative;
top: 0px; <-- not needed
left: 0px; <--- not needed
width: 400px;
padding-bottom: 0px;
background: blue;
border: none;
overflow: auto;
visibility: visible; <--- not needed
height: 200px;
}
//inner div style
#inhaltbox {
position: absolute;
top: 0px; <--- left or right also needs to be declared
overflow: hidden;
width: 400px;
height: 200px;
display: none; <---
display: block; <--- Choose one, not both
}
关于javascript - 将 div 样式设置为最大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9178808/