CSS ช่วยให้เราจัดรูปแบบรายการได้โดยการระบุพื้นหลัง คุณสมบัติ list-style การจัดรูปแบบแบบอักษร ฯลฯ คุณสมบัติ list-style เป็นคุณสมบัติแบบย่อสำหรับระบุ list-style-type, list-style-image และ list-style-position ในลำดับเดียวกัน
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติ CSS list-style ดังนี้:
Selector { list-style: /*value*/ }
ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงการจัดรูปแบบรายการ:
<!DOCTYPE html> <html> <head> <style> ul { display: flex; float: left; list-style-image: url("https://www.tutorialspoint.com/images/reactjs.png"); background: lightseagreen; list-style-position: inside; } li { background: azure; margin: 5px 20px; } </style> </head> <body> <h3>ReactJS</h3> <ul> <li>บทที่ 1</li> <li>บทที่ 2</li> <li>บทที่ 3</li> <li>บทที่ 4</li> <li>บทที่ 5</li> </ul> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:

ตัวอย่างเพิ่มเติม
<!DOCTYPE html> <html> <head> <style> ol { width: 40%; color: white; list-style: lower-greek inside; background-image: url("https://www.tutorialspoint.com/ethereum/images/ethereum-mini-logo.jpg"); } li { background-color: rgba(0,0,0,0.6); margin: 5px 30px; } </style> </head> <body> <h2>Ethereum</h2> <ol> <li>Smart Contracts</li> <li>Ganache</li> <li>การสร้างกระเป๋าเงิน</li> <li>การปรับใช้สัญญา</li> </ol> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:
