使用 CSS 为表单输入添加背景颜色

原创
ithorizon 5个月前 (10-19) 阅读数 50 #CSS

要向表单输入添加背景颜色,请使用background-color属性。

您可以尝试运行以下代码实现表单的背景颜色属性

示例

现场演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input[type=text] {
            width: 100%;
            padding: 10px 15px;
            margin: 5px 0;
            box-sizing: border-box;
            background-color: gray;
         }
      </style>
   </head>
   <body>
      <p>Fill the below form,</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
      <form>
         <label for = "subject">Subject</label>
         <input type = "text" id = "subject" name = "sub">
         <label for = "student">Student</label>
         <input type = "text" id = "student" name = "stu">
      </form>
   </body>
</html>

以上就是使用 CSS 为表单输入添加背景颜色的详细内容,更多请关注IT视界其它相关文章!



热门