[英]CSS dialog with header and auto content
I'm working on HTML/CSS dialog window which has header and scrollable body. 我正在使用具有标题和可滚动正文的HTML / CSS对话框窗口。 I want to have body sizable to its content, but show scrollbars in body if the dialog higher than browser window.
我想将正文调整为其内容,但是如果对话框高于浏览器窗口,则在正文中显示滚动条。 Unfourtantely I can't make body scrollable, how can I fix it?
毫无疑问,我无法使身体滚动,该如何解决? Here is the code that I use (jsFiddle: http://jsfiddle.net/4Xvfm/1/ ):
这是我使用的代码(jsFiddle: http : //jsfiddle.net/4Xvfm/1/ ):
<div class="dialog">
<div class="header">Header</div>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur, error, sunt, quaerat aliquid voluptatem dolorum in amet facere dolores cumque magnam placeat! Numquam, nisi, possimus facere iure eos minus repellat.
</div>
</div>
And CSS styles: 和CSS样式:
.dialog {
background-color: red;
max-width: 100%;
width: 400px;
max-height: 100%;
/* Place dialog at the center of the screen */
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.dialog > .header,
.dialog > .footer {
background-color: blue;
height: 50px;
}
.dialog > .content {
/* This doesn't work! */
overflow: auto;
}
更改溢出值以像“ overflow:scroll”一样滚动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.