目录

如何操作 - 联系表


了解如何使用 CSS 创建联系表单。


提交

亲自试一试 »


如何创建联系表

步骤 1) 添加 HTML

使用 <form> 元素来处理输入。您可以在我们的网站中了解更多相关信息PHP教程。然后为每个字段添加输入(带有匹配的标签):

示例

<div class="container">
  <form action="action_page.html">

    <label for="fname">First Name</label>
    <input type="text" id="fname" name="firstname" placeholder="Your name..">

    <label for="lname">Last Name</label>
    <input type="text" id="lname" name="lastname" placeholder="Your last name..">

    <label for="country">Country</label>
    <select id="country" name="country">
      <option value="australia">Australia</option>
      <option value="canada">Canada</option>
      <option value="usa">USA</option>
    </select>

    <label for="subject">Subject</label>
    <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>

    <input type="submit" value="Submit">

  </form>
</div>


步骤2)添加CSS:

示例

/* Style inputs with type="text", select elements and textareas */
input[type=text], select, textarea {
  width: 100%; /* Full width */
  padding: 12px; /* Some padding */ 
  border: 1px solid #ccc; /* Gray border */
  border-radius: 4px; /* Rounded borders */
  box-sizing: border-box; /* Make sure that padding and width stays in place */
  margin-top: 6px; /* Add a top margin */
  margin-bottom: 16px; /* Bottom margin */
  resize: vertical /* Allow the user to vertically resize the textarea (not horizontally) */
}

/* Style the submit button with a specific background color etc */
input[type=submit] {
  background-color: #04AA6D;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* When moving the mouse over the submit button, add a darker green color */
input[type=submit]:hover {
  background-color: #45a049;
}

/* Add a background color and some padding around the form */
.container {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
}
亲自试一试 »

提示:去我们的HTML 表单教程了解有关 HTML 表单的更多信息。

提示:去我们的CSS 表单教程了解有关如何设置表单元素样式的更多信息。

曾经听说过91xjr 空间?在这里,您可以从头开始创建您的网站或使用模板,并免费托管它。

免费开始❯

* 无需信用卡