当你点击 reddit 注册按钮时,一个漂亮的窗口弹出,屏幕的其余部分变黑。您可以单击屏幕的其余部分以关闭弹出窗口。
我知道我可以为此使用最外层的 div,但 reddit 是这样做的吗?他们是否也在动态更改外层 div 的属性?
最佳答案
这种技术被称为覆盖
,实现起来非常简单:
#overlay {
position: fixed;
z-index:103;
top: 0px;
left: 0px;
height:100%;
width:100%;
background-color: gray;
opacity: 0.7;
}
显示它的完整行为被称为 modal window .
Check out a live sample of the CSS above .
不过,考虑到所有因素,要使 float DIV 带有表单等,您将要使用为此制作的许多插件之一,例如 Thickbox或 jqModal .
关于javascript - reddit 是如何在弹出登录表单时让整个背景变黑的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/742812/