如何設置水平線的樣式

學習如何使用 CSS 設置 hr 元素的樣式。

如何設置水平線的樣式






水平線

您可以使用 border 屬性來設置 hr 元素的樣式:

實例

/* 紅色邊框 */
hr.new1 {
  border-top: 1px solid red;
}
/* 紅色虛線邊框 */
hr.new2 {
  border-top: 1px dashed red;
}
/* 紅色點狀邊框 */
hr.new3 {
  border-top: 1px dotted red;
}
/* 紅色粗邊框 */
hr.new4 {
  border: 1px solid red;
}
/* 綠色大圓角邊框 */
hr.new5 {
  border: 10px solid green;
  border-radius: 5px;
}

親自試一試

相關頁面

參考手冊:HTML hr 標簽