Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

วิธีจัดสไตล์ปุ่มข้อความด้วย CSS


นี่คือโค้ดตัวอย่างสำหรับการจัดสไตล์ปุ่มข้อความ (Text Buttons) ด้วย CSS

ตัวอย่าง

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> button {    border: none;    color: white;    font-weight: bolder;    padding: 20px;    font-size: 18px;    cursor: pointer;    border-radius: 6px; } .Success {    color: #4caf50; } .Success:hover {    background: #e7e7e7; } .Info {    color: #2196f3; } .Info:hover {    background: #e7e7e7; } .Warning {    color: #ff9800; } .Warning:hover {    background: #e7e7e7; } .Danger {    color: #f44336; } .Danger:hover {    background: #e7e7e7; } .Default {    color: black; } .Default:hover {    background: #e7e7e7; } </style> </head> <body> <h1>ตัวอย่างปุ่มข้อความ</h1> <button class="Success">Success</button> <button class="Info">Info</button> <button class="Warning">Warning</button> <button class="Danger">Danger</button> <button class="Default">Default</button> </body> </html>

ผลลัพธ์

โค้ดด้านบนจะแสดงผลดังนี้ −

วิธีจัดสไตล์ปุ่มข้อความด้วย CSS