/* 縮寫:width style color(順序不嚴格,建議依此) */
border: 2px solid #333;
/* 等效展開 */
border-width: 2px;
border-style: solid; /* none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset */
border-color: #333;
/* 四邊不同 */
border-top: 3px solid #e74c3c;
border-right: 2px dashed #3498db;
border-bottom: 1px dotted #2ecc71;
border-left: 4px double #9b59b6;
/* 縮寫四值:上 右 下 左 */
border-width: 3px 2px 1px 4px;
border-style: solid dashed dotted double;
border-color: #e74c3c #3498db #2ecc71 #9b59b6;
/* 單值:四角同半徑 */
border-radius: 8px;
/* 兩值:左上/右下、右上/左下 */
border-radius: 12px 4px;
/* 三值:左上、右上/左下、右下 */
border-radius: 12px 8px 4px;
/* 四值:左上、右上、右下、左下(順時針) */
border-radius: 16px 8px 4px 0;
/* 八值(水平/垂直半徑分離):水平半徑 / 垂直半徑 */
border-radius: 20px 10px 5px 0 / 10px 20px 0 5px;
.frame {
border: 20px solid transparent;
border-image: url("frame.png") 30 30 30 30 / 20px / 0 round;
/*
source: 圖片
slice: 從邊緣向內切 30px (上右下左)
width: 邊框寬度 20px
outset: 外擴 0
repeat: stretch | repeat | round | space
*/
}
.triangle-down {
width: 0; height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 15px solid #3498db;
}
.triangle { width: 0; height: 0; border: 8px solid transparent; }
.triangle-up { border-bottom-color: #333; }
.triangle-down { border-top-color: #333; }
.triangle-left { border-right-color: #333; }
.triangle-right { border-left-color: #333; }
.gradient-border {
border: 3px solid transparent;
background: linear-gradient(#fff, #fff) padding-box,
linear-gradient(135deg, #667eea, #764ba2) border-box;
border-radius: 12px;
}
@keyframes border-draw {
to { stroke-dashoffset: 0; }
}
.animated-border {
border: 2px solid transparent;
background: linear-gradient(90deg, #667eea, #764ba2) border-box;
background-size: 200% 100%;
animation: border-flow 2s linear infinite;
}
@keyframes border-flow {
to { background-position: -200% 0; }
}
table { border-collapse: collapse; }
th, td { border: 1px solid #ddd; }
box-sizing: border-box:width/height 包含 border + padding(推薦全站套用)outline 不佔空間、不影響佈局、不支援圓角、可用於焦點樣式box-shadow 可模擬多重邊框、內發光、不佔空間掌握邊框後,建議學習 CSS 盒模型 Margin/Padding 完整指南,建立精確的空間控制能力。