## border-radius 屬性
## 定義和用法
border-radius 屬性是一個簡寫屬性,用于設置四個 border-\*-radius 屬性。
提示:該屬性允許您為元素添加圓角邊框!
JavaScript 語法:object.style.borderRadius="5px"
## 語法
~~~
border-radius: 1-4 length|% / 1-4 length|%;
~~~
注釋:按此順序設置每個 radii 的四個值。如果省略 bottom-left,則與 top-right 相同。如果省略 bottom-right,則與 top-left 相同。如果省略 top-right,則與 top-left 相同。
| 值 | 描述 | 測試 |
| --- | --- | --- |
| *length* | 定義圓角的形狀。 | [測試](https://www.w3cschool.cn/statics/demosource/css-border-radius.html) |
| *%* | 以百分比定義圓角的形狀。 | [測試](https://www.w3cschool.cn/statics/demosource/css-border-radius.html) |
### 例子 1
~~~
border-radius:2em;
~~~
等價于:
~~~
border-top-left-radius:2em;
border-top-right-radius:2em;
border-bottom-right-radius:2em;
border-bottom-left-radius:2em;
~~~
### 例子 2
~~~
border-radius: 2em 1em 4em / 0.5em 3em;
~~~
等價于:
~~~
border-top-left-radius: 2em 0.5em;
border-top-right-radius: 1em 3em;
border-bottom-right-radius: 4em 0.5em;
border-bottom-left-radius: 1em 3em;
~~~
## 實例--向 div 元素添加圓角邊框:
~~~
div
{
border:2px solid;
border-radius:25px;
}
~~~
- CSS常用樣式控制
- background--背景
- Text--文本
- CSS屬性
- align-*
- animation-*
- appearance
- backface-visibility
- background
- background-attachment
- background-blend-mode
- background-clip
- background-color
- background-image
- background-origin
- background-position
- background-repeat
- background-size
- border
- border-bottom
- border-bottom-color
- border-bottom-left-radius
- border-bottom-right-radius
- border-bottom-style
- border-bottom-width
- border-collapse
- border-color
- border-image
- border-image-outset
- border-image-repeat
- border-image-source
- border-image-width
- Border-left
- border-left-color
- border-left-style
- border-left-width
- border-image-slice
- border-radius
- border-right
- border-right-color
- border-right-style
- border-right-width
- border-spacing
- border-style
- border-top
- border-top-color
- border-top-left-radius
- border-top-right-radius
- border-top-style
- border-top-width
- border-width
- bottom
- box-shadow
- box-sizing
- caption-side
- clear
- clip
- color
- column-count
- column-gap
- column-rule
- column-rule-color
- column-rule-style
- column-rule-width
- column-span
- column-width
- columns
- content
- counter-increment
- counter-reset
- cursor
- direction
- display
- Empty-cells
- filter(濾鏡)
- CSS 偽元素選擇器
- :active 選擇器
- :after 選擇器
- :before 選擇器
- :checked 選擇器
- :disabled 選擇器
- :empty 選擇器
- :enabled 選擇器
- :first-child 偽元素
- :first-letter 偽元素
- :first-line 偽元素
- :first-of-type 選擇器
- :focus 選擇器
- :hover 選擇器