วิธีการ - แบบฟอร์มด้วยไอคอน
เรียนรู้วิธีสร้างฟอร์มด้วยไอคอน
ลงทะเบียน
วิธีสร้างรูปแบบไอคอน
ขั้นตอนที่ 1) เพิ่ม HTML:
ใช้ <form> องค์ประกอบในการประมวลผลอินพุต คุณสามารถเรียนรู้เพิ่มเติมเกี่ยวกับสิ่งนี้ได้ในบทช่วยสอนPHP ของเรา จากนั้นเพิ่มอินพุตสำหรับแต่ละฟิลด์:
ตัวอย่าง
<form action="/action_page.php">
<h2>Register Form</h2>
<div class="input-container">
<i class="fa fa-user
icon"></i>
<input class="input-field" type="text"
placeholder="Username" name="usrnm">
</div>
<div
class="input-container">
<i class="fa fa-envelope
icon"></i>
<input class="input-field" type="text"
placeholder="Email" name="email">
</div>
<div
class="input-container">
<i class="fa fa-key
icon"></i>
<input class="input-field" type="password"
placeholder="Password" name="psw">
</div>
<button
type="submit" class="btn">Register</button>
</form>
ขั้นตอนที่ 2) เพิ่ม CSS:
ตัวอย่าง
* {box-sizing: border-box;}
/* Style the input container */
.input-container {
display: flex;
width: 100%;
margin-bottom: 15px;
}
/* Style the form
icons */
.icon {
padding:
10px;
background: dodgerblue;
color: white;
min-width: 50px;
text-align: center;
}
/* Style the input
fields */
.input-field {
width: 100%;
padding:
10px;
outline: none;
}
.input-field:focus {
border: 2px solid
dodgerblue;
}
/* Set a style for the submit button */
.btn {
background-color: dodgerblue;
color: white;
padding: 15px
20px;
border: none;
cursor: pointer;
width:
100%;
opacity: 0.9;
}
.btn:hover {
opacity: 1;
}
เคล็ดลับ:ไปที่การสอนแบบฟอร์ม HTMLเพื่อเรียนรู้เพิ่มเติมเกี่ยวกับแบบฟอร์ม HTML
เคล็ดลับ:ไปที่CSS Form Tutorialเพื่อเรียนรู้เพิ่มเติมเกี่ยวกับวิธีการจัดรูปแบบองค์ประกอบแบบฟอร์ม
เคล็ดลับ:ไปที่CSS Flexbox Tutorialเพื่อเรียนรู้เพิ่มเติมเกี่ยวกับโมดูลเค้าโครงกล่องแบบยืดหยุ่น