html - HTML && CSS 输入边框移动
问题描述
我有个问题。我正在用 HTML 和 CSS 制作注册表单。我在输入的焦点上放置了一个边框(单击后,会出现输入边框),但随后另一个输入开始移动。我该如何解决这些动作?这是我的代码:
input {
width: 450px;
height: 3.5vh;
margin-bottom: 1rem;
outline: none;
color: white;
border: 1px solid rgba(170, 170, 170, 0.3);
background: rgba(0, 0, 0, 0.5);
font-family: 'Poppins', sans-serif;
font-weight: bold;
border-radius: 3px;
}
input:focus {
border: 2px solid blueviolet;
outline: none!important;
}
<div class="inputs">
<input type="text" placeholder="User Name" name="name">
</div>
<div class="inputs">
<input type="email" placeholder="Email" name="email">
</div>
<div class="inputs">
<input type="password" placeholder="Password" name="password">
</div>
<div class="inputs">
<input type="password" placeholder="Confirm Password" name="confirmit">
</div>
<span class="img-text">Choose avatar: </span>
<input type="file" id="img" accept="image/*" style="border: none!important; background: none!important;">
<button class="register" type="submit" name="register">Register</button>
我真的很感激帮助。
解决方案
发生这种情况是因为您在焦点上添加了边框,但最初输入标签中没有边框,这就是您面临 UI 波动的原因。
要修复在输入中添加边框属性以及透明度。
input {
width: 450px;
height: 3.5vh;
margin-bottom: 1rem;
outline: none;
color: white;
background: rgba(0, 0, 0, 0.5);
font-family: 'Poppins', sans-serif;
font-weight: bold;
border-radius: 3px;
border: solid 2px transparent;
}
推荐阅读
- reactjs - 使用 Dockerfile 运行 Jest 测试
- powershell - PowerShell 使用调用命令时将文件写入本地计算机
- typo3 - TYPO3 页面 - 加载资源失败:服务器响应状态为 403
- r - 如何将数据框压缩为 R 中“是”或“否”值的矩阵?
- postgresql - pg sql 使用 ilike 运算符在数组中搜索文本
- android - 至少在滤镜 GLSurface 上应用时图像失真
- python - 计算每行最常见的 10 个单词
- c++ - 程序 1 在 Linux 管道上写入的数据有时会被程序 2 读取两次
- python - Python - Pandas,按时间间隔分组
- python - 在 django 中对标准用户模型进行分组