【发布时间】:2017-09-01 23:55:36
【问题描述】:
我有一个登录表单,当您将鼠标悬停在链接上时会显示它自己。所以基本上,当您将鼠标悬停在a 时,表单会将其规则display: none 更新为display: block
当我开始填写字段时,浏览器会根据之前的输入显示建议。但是当我想选择建议时,element 再次将自己设置为display: none。
我不想设置autocomplete="off"。
演示
* {
box-sizing: border-box;
}
form {
display: none;
}
div:hover form {
background-color: #f1f1f1;
display: block;
padding: 15px;
}
<p>Fill in a sample username and password, after that you get an fiddle error. Just reload the fiddle and then the autocomplete shows you suggestions</p>
<div class="hover">
<span>HOVER TO SHOW LOGIN FORM</span>
<form method="post">
<input type="text" id="username" name="username" placeholder="username" />
<input type="password" id="password" name="password" placeholder="password" />
<input type="submit" name="login" value="login" />
</form>
</div>
如何防止这种行为?
【问题讨论】:
-
你用的是哪个浏览器?
-
你可以添加 autocomplete="off" 属性
-
所有浏览器都存在同样的问题。 IE、FF 和 Chrome。我不想设置 autocomplete="off"
-
您在显示表单时显示悬停的问题,当自动完成打开时它不再悬停,如何将悬停更改为单击?或者你需要一个js解决方案来测试是否打开了autocompelte