通过 CSS 在表单文本字段中添加间距


若要在表单文本字段中添加间距,请使用 CSS 内边距属性。

你可以尝试运行以下代码:

示例

在线演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         input[type = text] {
            width: 100%;
            padding: 10px 15px;
            margin: 5px 0;
            box-sizing: border-box;
         }
      </style>
   </head>
   <body>
      <p>Fill the below form,</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>

更新于: 2020 年 6 月 23 日

9K+ 浏览量

开启您的职业生涯

通过完成课程获得认证

开始学习
广告