【发布时间】:2020-01-22 10:40:54
【问题描述】:
我需要使用 html 和 css 创建一个输入。
它必须有 icon , placeholder , icon 。
像这样:
我尝试通过这个 html 代码来创建它:
<div class="username">
<i class="fa fa-envelope icon"></i>
<input type="text" placeholder="Username">
</div>
<div class="password">
<i class="fa fa-envelope icon"></i>
<input type="password" placeholder="Password">
</div>
这个css代码:
.username input[type="text"]{
padding: 5px;
position: relative;
border-radius: 2px;
border:1px solid #ECF0EF;
height: 35px;
-webkit-box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
-moz-box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
}
.username i{
position: absolute;
z-index: 9999;
height: 10px;
line-height: 2;
}
.password input[type="password"]{
padding: 5px;
position: relative;
border-radius: 2px;
border:1px solid #ECF0EF;
height: 30px;
-webkit-box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
-moz-box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
box-shadow: 0px 0px 28px -15px rgba(0,0,0,1);
}
.password input::after{
content: '<i class="fa fa-envelope icon"> ';
}
.password i{
position: absolute;
z-index: 9999;
height: 10px;
line-height: 2;
}
但它不起作用。
这是Demo
我怎么能这样创作??
【问题讨论】:
-
我希望你能发现这个有用stackoverflow.com/questions/19350291/…
-
@devolasoji 谢谢,但我不能使用 javascript。只是 html 和 css