How to create: Contact Form
Learn how to create a contact form using CSS.
Contact Form
ພວກມັນວິທີທີ່ຈະສ້າງຕົວປະກາດການຄວາມສຳພັນ:
ກໍານົດບັນທຶກ 1 - ຕອບການ HTML:
ນຳໃຊ້ <form> ເພື່ອຈັດການການເຂົ້າ. ທ່ານສາມາດອົບຮົມຂໍ້ມູນຂອງພະຍານ PHP ຂອງພວກເຮົາຫຼາຍຂຶ້ນ.
ຫຼັງຈາກນັ້ນ ຕອບການເພີ່ມຢູ່ໃນບັນດາບັນພະຍານ (ແລະກັບຕົວແທນທີ່ຕາມ):
<div class="container"> <form action="action_page.php"> <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>
第二步 - 添加 CSS:
/* 为类型为 "text" 的输入框、选择元素和文本域设置样式 */ input[type=text], select, textarea { width: 100%; /* 全宽 */ padding: 12px; /* 一些内边距 */ border: 1px solid #ccc; /* 灰色边框 */ border-radius: 4px; /* 圆角边框 */ box-sizing: border-box; /* 确保内边距和宽度保持不变 */ margin-top: 6px; /* 下外边距 */ margin-bottom: 16px; /* Bottom margin */ resize: vertical /* 许用户垂直调整文本域的大小(而不是水平调整) */ } /* 为提交按钮设置特定的背景颜色等样式 */ input[type=submit] { background-color: #04AA6D; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; } /* 当鼠标悬停在提交按钮上时,添加更深的绿色背景 */ input[type=submit]:hover { background-color: #45a049; } /* 为表单容器添加背景颜色和一些内边距 */ .container { border-radius: 5px; background-color: #f2f2f2; padding: 20px; }
相关页面
教程:HTML 表单
教程:CSS 表单