html - 如何为具有全尺寸背景的登录表单设置模糊、居中和响应框的样式?
问题描述
我试图在具有全尺寸、居中背景图像的 HTML 页面(Angular)上构建登录表单,并且表单放置在背景模糊的 div 中,该表单位于浏览器的 x 轴和 y 轴的中心窗户。
这就是我走了多远:https ://codepen.io/surfermicha/pen/ZwpxBa
<div class="login-background-door2">
<div class="aero-background centered">
<h3>Here will be a login form later</h3>
</div>
</div>
不幸的是,我对此有一些问题:
- 居中的框不完全在中心
- 它没有响应。div 在小型设备上很小。我想要左右 10 像素的边距,但在更大的屏幕上最大宽度为 500 像素。
任何人都可以帮助编辑代码笔以获得有效的响应解决方案
解决方案
您可以根据需要设置媒体查询,就像我设置为 567px 一样,因为在您的中心块的 567px 视图之后,看起来不太好,所以我设置为 567px。
body, html {
font-family: "roboto", monospace;
color: #EEE;
padding: 0;
width: 100%;
margin: 0;
height: 100%;
overflow-x: hidden;
}
.aero-background::before {
content: '';
background: url("http://placekitten.com/2400/2000") center no-repeat;
filter: blur(6px);
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: -1;
pointer-events: none;
}
.aero-background {
border-radius: 5px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
border: 1px solid rgba(255, 255, 255, 0.1);
color: white;
align-items: center;
justify-content: center;
text-shadow: 0 0 10px black;
}
.centered {
max-width: 500px;
min-height: 300px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.login-background-door2 {
background: url("http://placekitten.com/2400/2000") center no-repeat;
height: 100%;
width: 100%;
overflow: hidden;
}
@media screen and (max-width: 567px) {
.centered {
width: 250px;
}
}
<div class="login-background-door2">
<div class="aero-background centered">
<h3>Here will be a login form later</h3>
</div>
</div>
推荐阅读
- gaussian-process - 条件多元正态的顺序抽样
- annotations - 旋转标签图适合散景
- python - 熊猫 groupby 并仅在整列每组一致时获取值
- powerquery - 为特定组保留一个月和一年的最后一行
- pytorch - Pytorch 如何构建计算图
- amazon-web-services - 如何将秘密信息传递给 ecs docker flags?
- r - ShinyApp DTedit 表中没有为类型错误注册处理程序
- python - 使用python获取表格标签数据的特定部分
- javascript - 如何打印出 jwt 令牌
- java - 即使您在系统上安装了 JDK,是否需要 Java SE 才能安装 Netbeans?