我试图让内部div显示y轴滚动条而不是外部div.
CSS
- div#container
- {
- overflow: auto;
- width: 90%;
- height: 65%;
- position: absolute;
- top: 100px;
- bottom: 0;
- left: 0;
- right: 0;
- margin: 0 auto -10px;
- padding: 10px;
- background-color: rgba(0,0.6);
- border:0px solid black;
- border-radius:15px;
- font-family: 'PT Sans',arial,serif;
- color:#ffffff;
- text-align:right;
- font-size:18px;
- }
- div#content
- {
- font-family: 'PT Sans',serif;
- color:#ffffff;
- text-align:left;
- font-size:14px;
- }
解决方法
你必须在div#container上设置overflow:auto不在div#container上,并以某种方式为div#内容指定高度:95%
这是一个小提琴:http://jsfiddle.net/TKDqT/9/
或者你也可以用jQuery指定高度:
- $("div#content").outerHeight( $("div#container").innerHeight() - $("div#content").position().top);
这比高度百分比更准确.