【问题标题】:What CSS do I have to apply so I can get this result [duplicate]我必须应用什么CSS才能得到这个结果[重复]
【发布时间】:2015-03-18 17:14:39
【问题描述】:
我正在编写一个简单的应用程序,它有一个登录表单,我想让用户名和密码字段更漂亮。更具体地说是这样的:
这是一张图片。如果它在网络上,我会检查 html,但事实并非如此。我想知道是否有人可以帮助使用 CSS,因为我对使用 CSS 不是很有信心。
【问题讨论】:
-
这结合了 CSS 渐变、三角形、背景图像纹理、边框和边框半径来制作圆角......所以你需要完全学习 CSS 才能做到这一点。 Try a tutorial.
标签:
html
css
input
css-shapes
【解决方案1】:
您可以为此使用伪元素:
.input {
margin: 5px;
width: 300px;
height: 30px;
position: relative;
border: 2px solid black;
border-radius: 5px;
}
.label {
display: inline-block;
height: 100%;
position: absolute;
top: 0;
left: 0;
width: 45%;
background: black;
color: white;
text-align: center;
line-height: 30px;
}
.label:after {
content: "";
position: absolute;
right: -15px;
top: 5px;
height: 0%;
border-left: 15px solid black;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
z-index: 8;
}
.input input[type="text"] {
position: absolute;
height: 100%;
width: 50%;
left: 50%;
padding: 0;
border: none;
outline: none;
}
<div class="input">
<div class="label">Username</div>
<input type="text" placeholder="input here" />
</div>
<div class="input">
<div class="label">Password</div>
<input type="text" placeholder="input here" />
</div>