热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使div全屏和可滚动?

如何解决《如何使div全屏和可滚动?》经验,为你挑选了1个好方法。

使用绝对值时,它会滚动但不会达到100%的高度:

.class {
 position: absolute;
 left: 0;
 right: 0;
 top: 0;
 bottom: 0;
 height: 100%;
 width: 100%;
 z-index: 1000000;
 background: rgba(0, 0, 0, 0.9);
}

固定后,它的高度为100%,但不会滚动

.class {
 position: fixed;
 left: 0;
 top: 0;
 height: 100%;
 width: 100%;
 z-index: 1000000;
 background: rgba(0, 0, 0, 0.9);
}

我想避免在子元素中添加固定的高度并制作它 overflow: scroll



1> Joseph Marik..:

您需要添加overflow:auto以便在内容溢出容器时滚动它.

.class {
    ...
    overflow:auto;
}

http://jsbin.com/kuqaqumude/1/edit?html,css,output

如对更多的细节overflow: autooverflow: visible,
请参见: http://www.w3.org/TR/CSS21/visufx.html#overflow-clipping


推荐阅读
author-avatar
玄天战猫
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有