นี่คือโค้ดสำหรับการสร้างปุ่มค้นหา (Search Button) พร้อมช่องป้อนข้อความ ด้วย CSS
ตัวอย่าง
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <style> body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } * { box-sizing: border-box; } input[type=text] { padding: 12px; font-size: 17px; border: 1px solid grey; float: left; width: 80%; background: #f1f1f1; } button { float: left; width: 20%; padding: 12px; background: rgb(14, 81, 204); color: white; font-size: 17px; border: 1px solid grey; border-left: none; cursor: pointer; } button:hover { background: #1b11a5; } </style> </head> <body> <h1>Search button example</h1> <form > <input type="text" placeholder="Search.." name="search"> <button type="submit"><i class="fa fa-search"></i></button> </form> </body> </html>
ผลลัพธ์
โค้ดด้านบนจะแสดงผลดังนี้ −
