1 回答
TA贡献2021条经验 获得超8个赞
您需要将背景移动到标题而不是裁剪它。除了标题背景之外,您还可以使用 :before 伪类。在我的示例中,您可以看到我从 CSS 中删除了绝对位置,并且代码变得干净:
尝试这样:
form {
position: relative;
margin: 0%;
padding: 0%;
position: relative;
width: 100%;
height: auto;
display: inline-block;
background: #f4f7f8;
border-radius: 0 0 20px 20px;
}
.center_form {
position: relative;
width: 50%;
display: inline-block;
height: auto;
text-align: center;
border-radius: 20px 20px 20px 20px;
-moz-box-shadow: 1px 1px 15px 1px black;
-webkit-box-shadow: 1px 1px 15px 1px black;
box-shadow: 1px 1px 15px 1px black;
}
.center_form--header {
position: relative;
border-radius: 20px 20px 0 0;
height: auto;
text-align: center;
color: white;
padding-bottom: 2%;
padding-top: 2%;
border-radius: 20px 20px 0 0;
}
.center_form--header:before{
content:'';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url(https://i.postimg.cc/bw0JjXgn/8-bit-game-wallpaper-42148.jpg);
background-color: rgba(0, 0, 0, 0.4);
background-repeat: no-repeat;
background-position: center;
border-radius: 20px 20px 0 0;
filter: blur(2px);
-webkit-filter: blur(2px);
}
#formtitle {
position: relative;
display: inline-block;
width: 100%;
margin: 0;
font-size: 15px;
text-transform: uppercase;
font-family: 'Press Start 2P', cursive;
}
.center_form--elements input[type="text"] {
position: relative;
width: 90%;
height: 10%;
margin-top: 2%;
margin-left: 3%;
display: block;
border: none;
outline: none;
border-bottom: 1px solid #ddd;
background: #f4f7f8;
font-size: 18px;
margin-right: auto;
}
.center_form--elements input[type="submit"] {
position: relative;
margin-top: 3%;
margin-bottom: 3%;
-moz-box-shadow: 1px 1px 15px 1px black;
-webkit-box-shadow: 1px 1px 15px 1px black;
box-shadow: 1px 1px 15px 1px black;
background-color: #1A1D1E;
border: 1px solid #1A1D1E;
display: inline-block;
cursor: pointer;
color: #FFFFFF;
font-family: 'Open Sans Condensed', sans-serif;
font-size: 14px;
padding: 1% 5%;
text-decoration: none;
text-transform: uppercase;
}
<div class="center_form">
<div class="center_form--header">
<h2 id="formtitle">Press start!</h2>
</div>
<form>
<div class="center_form--elements">
<input placeholder="Name" type="text">
<input placeholder="Email" type="text">
<input type="submit" value="START">
</div>
</form>
</div>
- 1 回答
- 0 关注
- 90 浏览
添加回答
举报