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

คุณสมบัติ Outline Shorthand Property ใน CSS


คุณสมบัติ outline shorthand property สามารถกำหนดเพื่อวาดเส้นรอบขอบขององค์ประกอบด้วยรูปแบบเฉพาะ (จำเป็น), ความหนา และสี แต่ outline ไม่ใช่ส่วนหนึ่งของมิติขององค์ประกอบ ต่างจากคุณสมบัติ border

ไวยากรณ์

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

Selector {    outline: /*value*/ }

ตัวอย่าง

ลองดูตัวอย่างของคุณสมบัติ outline Shorthand:

<!DOCTYPE html> <html> <head> <title>CSS outline Shorthand</title> <style> span {    margin: 15px;    padding: 20px;    border-style: solid;    border-color: #f28500 #dc3545;    position: absolute;    outline: 5px double green;    border-radius: 50%; } #showDiv {    margin:auto;    border-style: solid;    border-color: darkmagenta dodgerblue;    outline: groove black;    height: 80px;    width: 80px; } #container {    width:50%;    margin:50px auto; } </style> </head> <body> <div id="container"> <div id="showDiv"><span></span></div> </div> </body></html>

ผลลัพธ์

ผลลัพธ์สำหรับโค้ดข้างต้น:

คุณสมบัติ Outline Shorthand Property ใน CSS

ตัวอย่าง

ลองดูตัวอย่างเพิ่มเติมของคุณสมบัติ outline Shorthand:

<!DOCTYPE html> <html> <head> <title>CSS outline Shorthand</title> <style> #container {    width:50%;    margin:50px auto; } p {    margin:auto;    border-style: ridge;    border-width: 10px;    border-color: orange;    outline: 5px dashed yellow; } </style> </head> <body> <div id="container"> <p>Coding Ground is loved by millions of programmers around the globe.</p> </div> </body> </html>

ผลลัพธ์

ผลลัพธ์สำหรับโค้ดข้างต้น:

คุณสมบัติ Outline Shorthand Property ใน CSS