我有一个内容区域,其行为方式如下:
- 如果没有垂直溢出,则内容垂直居中(目前通过 实现
display:table/-cell
) - 除非有垂直溢出,否则不显示滚动条
- 包含 div 的高度永远不会改变
我只能满足第一点 -小提琴:
http://jsfiddle.net/PTSkR/119/
这是我的html:
<div class="row-fluid card-box">
<div class="span4 side-study-box">
<div class="side-box-content">
<pre class="text-content-saved">TEST
TEST</pre>
</div>
</div>
</div>
CSS:
.side-study-box {
background-color: white;
color: black;
border: 1px solid #3D6AA2;
text-align: center;
height: 160px !important;
max-height: 160px !important;
display: table !important;
margin: 0px !important;
margin-left: -1px !important;
position: relative;
overflow-y: scroll !important;
}
.side-study-box .side-box-content {
width: calc(100%);
height: 160px !important;
float: right;
display: table;
overflow-y: scroll !important;
background-color: white;
}
/*#region CONTENT AREAS */
/*#region TEXT CONTENT */
.side-study-box .text-content-saved {
width: calc(100%+29px) !important;
font-size: 24px;
display: table-cell;
vertical-align: middle;
text-align: center;
height: 160px !important;
max-height: 160px !important;
background-color: white;
padding: 0px !important;
margin: 0px !important;
border: 0px !important;
overflow-y: scroll !important;
}