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>

我非常感谢您的帮助。

丹斯曼

如果要增加边框宽度,则可以使用插入框阴影代替。

另外,最好* { box-sizing: border-box }避免添加此类问题。

* {
  box-sizing: border-box;
}

input {
  width: 450px;
  height: 3.5vh;
  margin-bottom: 1rem;
  outline: none;
  color: white;
  border: none;
  box-shadow: inset 0 0 0 1px rgba(170, 170, 170, 0.3);
  background: rgba(0, 0, 0, 0.5);
  font-family: 'Poppins', sans-serif;
  font-weight: bold;
  border-radius: 3px;
  min-height: 40px;
  padding-left: 10px;
}

input:focus {
  box-shadow: inset 0 0 0 2px 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>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章