html - 具有密码属性的输入标签在聚焦时将移动站点更改为桌面
问题描述
这是一个简单的表单,其中包含电子邮件地址的输入字段和密码的输入字段。您可以毫无问题地输入您的电子邮件地址,它会保持其大小并且不会改变,除了焦点时输入背景颜色的微小变化。
然而,当聚焦时,密码会将本网站的移动版本更改为桌面版本。一旦你专注于其他事情,比如电子邮件,桌面网站就会变回移动版本。这不会发生在 chrome DevTools 上。问题似乎只出在移动版的 chrome 上。
我认为这与chrome如何处理“密码”属性有关。如何防止 chrome 仅仅因为密码而将移动网站更改为桌面并返回?
HTML
<form class="loginform" action="includes/login.inc.php" method="POST">
<h1>Log-in</h1>
<label for="userEmail">Email</label><br>
<input name="userEmail" autocomplete="username" type="text" placeholder="Email"><br>
<label for="userPwd">Wachtwoord</label><br>
<input name="userPwd" type="password" autocomplete="current-password" placeholder="Wachtwoord">
<br>
<input name="onthoudtmij" type="checkbox"><label for="onthoudtmij" style="display: inline-block;">Onthoudt mij</label>
<br>
<input type="submit" name="submit" value="Log-in">
<br>
<br>
<h1>Nog geen account? <a href="registreren.php">klik hier!</a></h1>
<br>
<a href="reset-wachtwoord.php">Wachtwoord vergeten? klik hier!</a>
</form>
CSS
@media screen and (max-width: 425px) and (orientation: portrait)
input[type=text], input[type=password], input[type=email], input[type=tel] {
width: auto;
}
input[type=text], input[type=password], input[type=email], input[type=tel] {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: none;
border-bottom: 2px solid #256578;
}
@media screen and (max-width: 425px) and (orientation: portrait)
p, li, h4, td, label, input, textarea {
font-size: 4.5vw;
padding: 0;
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=tel]:focus {
background-color: #c4c4c4;
}
解决方案
推荐阅读
- regex - 用于解析查询输出的正则表达式
- mirth - 跟踪配置更改及其实际的全局状态
- laravel - 我应该在关系中使用 index() 吗?
- java - 没有 LDAP 密码的 Spring 安全性
- javascript - 未在 Angular (6) 组件中获取在 textarea 中创建的标记
- azure-devops - VSTS:将部署失败发送到分发列表?
- shell - 如何在shell脚本中返回函数中传递的参数?
- c# - 具有两个泛型参数和推理的 C# 泛型方法
- jenkins - 在 Jenkinsfile 中使用变量时如何保留所有 shell 命令
- sql - SQL Server 比较日期时间和字符