【问题标题】:HTML input form border not styling correctlyHTML 输入表单边框样式不正确
【发布时间】:2017-05-12 03:40:39
【问题描述】:

我试图在我的表单文本输入周围设置一个纯黑色边框,但该边框的样式不正确。这是我的代码:

#forminput {
  border: solid black !important;
  border-top: solid black !important;
  border-bottom: solid black !important;
  border-width: 0 2px !important;
  border-radius: 2px;
}
button {
  width: 100px !important;
  height: 30px !important;
  background-color: #095ba0 !important;
  border: 1px !important;
  border-color: #095ba0 !important;
  color: #fff !important;
  font-family: 'Roboto', sans-serif !important;
  font-weight: 400 !important;
  cursor: pointer !important;
  border-radius: 2px !important;
}
<form action="*" method="POST">
  <input id="forminput" type="text" name="uid" placeholder="Username" ><br><br>
  <input id="forminput" type="password" name="pwd" placeholder="Password" ><br><br>
  <button type="submit">Sign In</button>
</form>

但我的表单输入如下所示。我究竟做错了什么? .

【问题讨论】:

  • 请不要滥用!important

标签: html css


【解决方案1】:

您将顶部和底部边框宽度设置为0

不要那样做。

#forminput {
  border: solid black!important;
  border-top: solid black!important;
  border-bottom: solid black!important;
  border-width: 2px!important;
  border-radius: 2px;
}
&lt;input id="forminput"&gt;

您可以在使用时删除所有多余的东西

#forminput {
  border: solid black 2px;
  border-radius: 2px;
}
&lt;input id="forminput"&gt;

【讨论】:

  • @isaa6 如果您找到最能解决您的问题的答案,请随时将其标记为已接受。
【解决方案2】:

试试:

#forminput {
    border: 2px solid #000;
}

这将在您输入的顶部、右侧、底部和左侧放置一个 2px 纯黑色边框。

【讨论】:

    猜你喜欢
    • 2013-04-16
    • 1970-01-01
    • 2014-10-15
    • 2011-12-18
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多