javascript - 在密码字段内放置密码可见性图标
问题描述
我有以下代码。
<div class="login-password">
<label for="password" class="form-label"
>Enter your password</label
>
<input
id="loginPassword"
type="password"
class="form-control"
placeholder="Enter your password"
/>
<i
class="bi bi-eye-slash"
id="togglePassword"
style="margin-left: -30px; cursor: pointer"
></i>
</div>
当我这样做时,密码可见性图标如下图所示。
如何将可见性图标放置在密码字段中。
解决方案
以marketwatch.com 的登录为例,您必须将<i> 标签的css 属性“位置”设置为“绝对”。这将允许您将其放置在输入框中。也许是这样的:
.bi-eye-slash {
width: 25px;
height: 25px;
position: absolute;
z-index: 200;
top: 28px;
right: 10px;
cursor: pointer;
}
推荐阅读
- mongodb - 在mongod php中更新数组中的多个元素
- ruby - 使用 YUM 在 AIX 7.2 中安装 Ruby
- r - 对于具有 2 个级别和两个级别上的值的变量,错误“对比只能应用于具有 2 个或更多级别的因素”
- c++ - Qt grabtoimage() 和 scale 产生两个重叠的图像?
- c++ - 格式化 foreach 宏与使用 clang-format 的循环相同
- javascript - React 组件类型错误问题
- python - pyinstaller 未加载任何依赖项
- java - 为什么模拟类不进入非模拟函数?
- offline - Gatsby 离线部署
- moodle - 在 Moodle 的主体中传递参数