html - 如果底部低于视口,CSS将元素垂直拉伸到底部
问题描述
我有一个移动响应菜单,它隐藏在左边,当有人点击汉堡包时会出来。完美运行,除了..
背景是一个<a>
元素,样式如下:
.backdrop.expanded,
.main-menu[aria-expanded="true"] + .backdrop {
position: absolute;
display: block;
content: "";
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 998;
background: #000;
background: rgba(0,0,0,.50);
cursor: default;
}
但是当它打开时,它的垂直范围是到视口的底部。我希望它扩展到页面底部。我该怎么做呢?
请注意,我希望人们在菜单打开时滚动,因为它可能会有所帮助。
解决方案
尝试这样的事情:
.backdrop.expanded,
.main-menu[aria-expanded="true"] + .backdrop {
position: absolute;
display: block;
content: "";
left: 0;
top: 0;
right: 0; /* instead of: width: 100%; */
bottom: 0; /* instead of: height: 100%; */
z-index: 998;
background: #000;
background: rgba(0,0,0,.50);
cursor: default;
}
作为相对的width
,对...height
没有影响position: absolute
推荐阅读
- node.js - 如何使用 nodejs/multer 使用 react-redux-saga 添加带有图像的项目
- r - 官员包是否支持旧格式的PPT文件(Window 97-2003)
- javascript - 为什么我可以返回一个递归运行的承诺?
- javascript - Firefox 不会转换到下一张图片
- ios - How to know if external keyboard is active in iOS
- xslt - select multiple attribute values in xslt
- flutter - 如何将 Flutter_App_link 分享到 facebook、twitter、instagram 等社交媒体?
- python-3.x - O如何使用python从图像的特定区域提取文本?
- node.js - 将大量数据保存到mongodb
- android - 如何在我的 Anko 布局中设置 topMargin