<label for="name">Name:</label> <input type="tex"/>

自适应美观的html表格代码

HTML

<form>
  <div class="form-group">
    <label for="name">Name:</label>
    <input type="text" class="form-control" id="name" required>
  </div>
  <div class="form-group">
    <label for="email">Email:</label>
    <input type="email" class="form-control" id="email" required>
  </div>
  <div class="form-group">
    <label for="message">Message:</label>
    <textarea class="form-control" id="message" rows="5" required></textarea>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

css

form {
  width: 80%;
  margin: 0 auto;
  border: 1px solid #ccc;
  padding: 20px;
  border-radius: 5px;
}

.form-control {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.btn {
  width: 100%;
  background-color: #4CAF50;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.btn:hover {
  background-color: #45a049;
}

@media (max-width: 600px) {
  form {
    width: 90%;
    padding: 10px;
  }
  .form-control {
    width: 100%;
    margin-bottom: 10px;
  }
  .btn {
    width: 100%;
    padding: 12px 20px;
  }
}

Check Also

input file字段选择图片之后怎么实现预览(还未上传到服务器的情况下)

$("#txt_image") …

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注