[英]Positioning problem of a child element in css on Firefox and internet explorer
I'm trying to properly position the toggle eye of the password field using CSS.The problem is the positioning works well in google chrome but it's not working in firefox and ie.I tried to figure out the solution but being a beginner in web development I didn't get a solution.我正在尝试使用 CSS 正确定位密码字段的切换眼。问题是定位在 google chrome 中运行良好,但在 firefox 中不起作用,即。我试图找出解决方案,但作为 Web 开发的初学者我没有得到解决方案。 Please help me to figure out the solution.请帮我找出解决方案。
My HTML part我的 HTML 部分
<div id="password">
<label for="pwd">Password</label>
<div>
<input type="password" id="pwd" name="pass_word" autocomplete="off" maxlength="12" value="<?php echo $pwd; ?>">
<span class="icon"><i id="show-pwd" class="far fa-eye hide"></i></span>
<span class="icon"><i id="hide-pwd" class="far fa-eye-slash"></i></span>
</div>
<div id="perr" class="err"><?php echo $pwderr; ?></div>
</div>
<div id="confirm-password">
<label for="cnfpwd">Confirm Password</label>
<div>
<input type="password" id="cnfpwd" name="cnf_pwd" autocomplete="off" maxlength="12" value="<?php echo $cpwd; ?>">
<span class="icon"><i id="show-cnfpwd" class="far fa-eye hide"></i></span>
<span class="icon"><i id="hide-cnfpwd" class="far fa-eye-slash"></i></span>
</div>
<div id="cperr" class="err"><?php echo $cpwderr; ?></div>
</div>
My CSS part我的 CSS 部分
.confirm-password{
position: relative;
}
.icon{
position: absolute;
transform: translate3d(-140%,40%,0);
color: #555;
}
The first image shows how it looks in chrome and the second shows how it looks in firefox.第一张图片显示了它在 chrome 中的样子,第二张图片显示了它在 Firefox 中的样子。
Your div
has an ID of confirm-password
but your CSS rule is for a class: .confirm-password
.您的div
的 ID 为confirm-password
但您的 CSS 规则适用于一个类: .confirm-password
。 Change .
改变.
to #
and your div
will now have position: relative
assigned to it. to #
并且您的div
现在将具有position: relative
分配给它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.