
- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 度量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 平移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z 索引
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪下
- CSS - 書寫模式
- CSS - Unicode 雙向演算法
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大塊尺寸
- CSS - 最小塊尺寸
- CSS - 混合模式
- CSS - 最大內聯尺寸
- CSS - 最小內聯尺寸
- CSS - 偏移量
- CSS - 重音顏色
- CSS - 使用者選擇
- CSS 高階
- CSS - 網格佈局
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 圖層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - Important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾斷開
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 提示框
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - border-block 屬性
CSS border-block 屬性是用於一次性為 border-block-color、border-block-style 和 border-block-width 分配值的簡寫屬性。border-block-style 是必填引數。如果未提及其他引數,則將使用預設值。此屬性取決於塊的方向,該方向由書寫模式確定。
語法
border-block: border-block-width border-block-style border-block-color | initial | inherit;
屬性值
值 | 描述 |
---|---|
它指定塊方向上邊框的寬度。預設值為 medium。 | |
它指定塊方向上邊框的樣式。預設值為 none。 | |
它指定塊方向上邊框的顏色。預設值為文字顏色。 | |
initial | 這將屬性設定為其預設值。 |
inherit | 這從父元素繼承屬性。 |
CSS 邊框塊屬性示例
以下示例使用不同的值解釋了 border-block 屬性。
設定邊框寬度
要設定邊框的寬度,我們使用 border-block 屬性的 border-block-width 元件。在以下示例中,我們為 border-block-width 屬性使用了“thick”和 10px 寬度。
示例
<!DOCTYPE html> <html> <head> <style> #width1 { padding: 30px; border-block-style: solid; border-block-width: thick; } #width2 { padding: 30px; border-block-style: solid; border-block-width: 10px; } </style> </head> <body> <h2>CSS border-block property</h2> <p id="width1"> This first example shows the width property of the border-block with thick value. </p> <p id="width2"> This second example shows the width property of the border-block with 10px value. </p> </body> </html>
設定邊框樣式
要設定邊框的樣式,我們使用 border-block 屬性的 border-block-style 元件。在以下示例中,我們為 border-block-style 屬性使用了“solid”和“dashed”樣式。
示例
<!DOCTYPE html> <html> <head> <style> #style1 { padding: 30px; border-block-style: solid; } #style2 { padding: 30px; border-block-style: dashed; } </style> </head> <body> <h2>CSS border-block property</h2> <p id="style1"> This first example shows the style property of the border-block with solid value. </p> <p id="style2"> This second example shows the style property of the border-block with dashed value. </p> </body> </html>
設定邊框顏色
要設定邊框的顏色,我們使用 border-block 屬性的 border-block-color 元件。在以下示例中,我們為 border-block-color 屬性使用了“red”和“blue”顏色。
示例
<!DOCTYPE html> <html> <head> <style> #color1 { padding: 30px; border-block-style: solid; border-block-color:red; } #color2 { padding: 30px; border-block-style: solid; border-block-color:blue; } </style> </head> <body> <h2>CSS border-block property</h2> <p id="color1"> This first example shows the color property of the border-block with red value. </p> <p id="color2"> This second example shows the color property of the border-block with blue value. </p> </body> </html>
一次設定所有值
要一次設定寬度、樣式和顏色的值,我們可以簡單地使用 border-block 屬性,並一次提供所有值。在以下示例中,寬度為 5px,樣式為 dashed,顏色為綠色。
示例
<!DOCTYPE html> <html> <head> <style> #block { padding: 30px; border-block: 5px dashed green; } </style> </head> <body> <h2>CSS border-block property</h2> <p id="block"> This example shows the border-block property defining all values at once. </p> </body> </html>
使用書寫模式設定邊框塊
在 border-block 的上下文中,writing-mode 會影響邊框的方向。預設情況下,邊框水平顯示,但是透過更改書寫模式,可以更改邊框的方向。
- 水平-tb:邊框水平顯示。
- 垂直-lb:邊框垂直顯示。
這些在以下示例中顯示。
示例
<!DOCTYPE html> <html> <head> <style> #horizontal { inline-size: 200px; padding: 10px; writing-mode: horizontal-tb; border-block: 5px dashed red; } #vertical { inline-size: 200px; padding: 10px; writing-mode: vertical-rl; border-block: 5px dashed green; } </style> </head> <body> <h2>CSS border-block property</h2> <div> <p id="horizontal">This example shows the horizontal boder.</p> </div> <div> <p id="vertical"> This example shows the vertical border.</p> </div> </body> </html>
支援的瀏覽器
屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
border-block | 87.0 | 87.0 | 66.0 | 14.1 | 73.0 |
css_properties_reference.htm
廣告