【发布时间】:2016-05-23 23:21:43
【问题描述】:
所以我在正在制作的网页上登录时有一个模糊的图像 div。
这是目前的样子:
现在,图像的模糊部分应该只在页面中间,我的尺寸如下面的 SCSS 所示:
//Variables
$background_image: url(../img/bg.png);
$background_fallback: #C0C0C0;
body {
padding: 0; margin: 0;
background-image: $background_image;
background-position: 0px 0px;
background-repeat: repeat;
color: #333;
animation: bg 40s linear infinite;
min-height: 100%;
width: 100%;
}
.login_container {
margin: auto;
overflow: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
width: 40%;
height: 60%;
.login_container_bg {
position: fixed;
left: 0; right: 0; z-index: 1;
display: block;
background-image: $background_image;
width: 100%;
height: 100%;
-webkit-filter: blur(2px);
-moz-filter: blur(2px);
-o-filter: blur(2px);
-ms-filter: blur(2px);
filter: blur(2px);
animation: bg 40s linear infinite;
}
.login_container_inner {
position: fixed;
left: 0; right: 0;
z-index: 2;
margin-left: 20px; margin-right: 20px;
}
}
@keyframes bg {
from { background-position: 0 0; }
to { background-position: 0 1000px; }
}
这是我使用的 HTML 结构:
<body>
<div class="login_container">
<div class="login_container_bg"></div>
<div class="login_container_inner">
Hello. It's me.
</div>
</div>
</body>
如您所见,背景的模糊部分扩展了页面的宽度。我希望模糊位只是内部的宽度和高度 - 应该是页面的 50% 和 50% (x, y)
【问题讨论】:
-
您的 .login_container_inner 已经居中。请提供更多您期望的细节。
-
@SebastianWiteczek 如您所见,背景的模糊部分扩展了页面的宽度。我希望模糊位只是内部的宽度和高度 - 应该是页面的 50% 和 50% (x, y)