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

คุณสมบัติ border แบบย่อใน CSS


คุณสมบัติ border ใช้สำหรับกำหนดคุณสมบัติขอบสำหรับองค์ประกอบ เป็นคุณสมบัติแบบย่อสำหรับ border-width, border-style และ border-color

ไวยากรณ์

ไวยากรณ์ของคุณสมบัติ CSS border ดังนี้:

Selector {    border: /*value*/ }

ตัวอย่าง

ตัวอย่างต่อไปนี้แสดงคุณสมบัติ CSS border:

<!DOCTYPE html> <html> <head> <style> img {    margin-top: 14px;    margin-left: 30px;    border: 2px solid orange;    box-shadow: 0 0 12px 1px black; } #demo {    border: 4px dotted magenta; } </style> </head> <body> <img src="https://www.tutorialspoint.com/swing/images/swing-mini-logo.jpg">   <img id="demo" src="https://www.tutorialspoint.com/scala/images/scala-mini-logo.jpg"> </body> </html>

ผลลัพธ์

ได้ผลลัพธ์ดังนี้:

คุณสมบัติ border แบบย่อใน CSS

ตัวอย่างเพิ่มเติม

<!DOCTYPE html> <html> <head> <style> table {    margin: 1em;    border: 3px dashed green; } td {    font-size: 24px;    border: 2px double navy; } </style> </head> <body> <table> <tr> <td>This</td> <td>text</td> </tr> <tr> <td>is</td> <td>demo</td> </tr> </table> </body> </html>

ผลลัพธ์

ได้ผลลัพธ์ดังนี้:

คุณสมบัติ border แบบย่อใน CSS