gpt4 book ai didi

html - 在右侧的输入字段内添加 fa eye 图标,这是响应式的

转载 作者:搜寻专家 更新时间:2023-10-31 08:49:45 25 4
gpt4 key购买 nike

我正在尝试在右侧添加一个眼睛图标。在我的原始代码中,它显示在右侧但没有响应,并且会在屏幕尺寸更改时移动。

下面是一个松散的实现。我希望它应该在输入字段在两个密码字段中结束之前显示在右侧。目前它显示但不正确。全屏测试。

.login-form {
margin: 20px 0 0 0;
}

.login-form input[type=text] {
background: #fff;
border: none;
border-radius: 8px;
position: relative;
font-size: 15px !important;
display: inline-block;
outline: none;
width: 100%;
height: 30px !important;
padding: 18px 0 18px 20px;
margin-bottom: 15px !important;
color: #666 !important;
border: 1px solid grey;
}

.login-left {
width: 44%;
margin: 0 0 0 5%;
display: inline-block;
float: left;
}

.login-right {
width: 44%;
margin: 0 5% 0 0;
display: inline-block;
float: right;
}

@media screen and (max-width:767px) {
.login-width {
width: 95% !important;
}
.login-left {
width: 90%;
margin: 0 auto;
display: block;
float: none;
}
.login-right {
width: 90%;
margin: 0 auto;
display: block;
float: none;
}
}

.p-viewer {
z-index: 9999;
position: absolute;
left: 560px;
margin-top: -60px;
}

.fa-eye {
color: #000;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="login-form">
<div class="login-left">
<div class="clearfix"></div>
<input type="text" placeholder="Email *"/>
<div class="clearfix"></div>
<input type="text" placeholder="Password *"/>
<span class="p-viewer">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
<div class="clearfix"></div>
</div>
<div class="login-right">
<div class="clearfix"></div>
<input type="text" placeholder="Confirm email *"/>
<div class="clearfix"></div>
<input type="text" placeholder="Confirm password *"/>
<span class="p-viewer2">
<i class="fa fa-eye" aria-hidden="true"> </i>
</span>
<div class="clearfix"></div>
<br>
</div>

最佳答案

CSS:

.login-form {
width: 100%;
margin: 20px 0 0 0;
}

.login-left {
width: 50%;
float: left;
}

.login-right {
width: 50%;
float: right;
}

.login-form input[type=text] {
background: #fff;
border: none;
border-radius: 8px;
position: relative;
font-size: 15px !important;
display: inline-block;
outline: none;
width: 100%;
height: 30px !important;
padding: 18px 0 18px 0px;
margin-bottom: 15px !important;
color: #666 !important;
border: 1px solid grey;
}
.pwd{
position: relative;
}
.p-viewer {
z-index: 9999;
position: absolute;
top: 30%;
right: 10px;
}

.fa-eye {
color: #000;
}


@media screen and (max-width:767px) {
.login-width {
width: 95% !important;
}
.login-left {
width: 90%;
margin: 0 auto;
display: block;
float: none;
}
.login-right {
width: 90%;
margin: 0 auto;
display: block;
float: none;
}
}
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
<link rel="stylesheet" type="text/css" href="demo.css">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<div class="login-form">
<div class="login-left">
<div class="clearfix"></div>
<input type="text" placeholder="Email *"/>
<div class="clearfix"></div>
<div class="pwd">
<input type="text" placeholder="Password *"/>
<span class="p-viewer">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
</div>
<div class="clearfix"></div>
</div>
<div class="login-right">
<div class="clearfix"></div>
<input type="text" placeholder="Confirm email *"/>
<div class="clearfix"></div>
<div class="pwd">
<input type="text" placeholder="Password *"/>
<span class="p-viewer">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
</div>
<div class="clearfix"></div>
</div>
</div>
</body>
</html>
在您的代码页响应问题是在这里:

.login-form input[type=text] {  
padding: 18px 0 18px 20px;}

因为首先你给出了 100% 宽度 + 填充,所以产生了问题。

你的眼睛问题解决了这些代码:

<div class="pwd">
<input type="text" placeholder="Password *"/>
<span class="p-viewer">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
</div>

只需添加带有 position:responsive 和 next class = p-viewer 的 div 标签,添加 position:absolute 就不会产生位置问题...

此代码完全响应且更改简单

关于html - 在右侧的输入字段内添加 fa eye 图标,这是响应式的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56732879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com