# UI
增加了一些新的用戶界面特性來調整元素尺寸,框尺寸和外邊框。
在本章中,您將了解以下的用戶界面屬性:
- resize
- box-sizing
- outline-offset
**注意:**Firefox、Chrome 以及 Safari 支持 resize 屬性。Internet Explorer、Chrome、Safari 以及 Opera 支持 box-sizing 屬性。Firefox 需要前綴 -moz-。所有主流瀏覽器都支持 outline-offset 屬性,除了 Internet Explorer。
### resize
resize 屬性指定一個元素是否應該由用戶去調整大小。可以使用 `resize:both`, `resize:vertical` 或者 `resize:horizontal`,用來分別設置元素是可以水平、垂直調整,垂直調整,水平調整。
例子
~~~
.div-both {
border: 1px solid green;
margin-top: 20px;
padding: 15px 30px;
width: 250px;
resize: both;
overflow: auto;
}
.div-horizontal {
border: 1px solid green;
margin-top: 20px;
padding: 15px 30px;
width: 250px;
resize: horizontal;
overflow: auto;
}
.div-vertical {
border: 1px solid green;
margin-top: 20px;
padding: 15px 30px;
width: 250px;
resize: vertical;
overflow: auto;
}
~~~
### box-sizing
box-sizing 允許您以確切的方式定義適應某個區域的具體內容
例子
~~~
.box-sizing {
box-sizing: border-box;
-moz-box-sizing: border-box; /* Firefox */
width: 50%;
border: 1em solid red;
float: left;
}
~~~
### outline-offset
outline-offset 屬性對輪廓進行偏移,并在超出邊框邊緣的位置繪制輪廓。
輪廓與邊框有兩點不同:
- 輪廓不占用空間
- 輪廓可能是非矩形
例子
~~~
.outline-offset {
width: 180px;
height: 80px;
border: 1px solid red;
outline: 1px solid green;
outline-offset: 20px;
}
~~~
### 屬性
| 屬性 | 說明 | CSS |
|-----|-----|-----|
| [appearance](#) | 允許您使一個元素的外觀像一個標準的用戶界面元素 | 3 |
| [box-sizing](#) | 允許你以適應區域而用某種方式定義某些元素 | 3 |
| [icon](#) | Provides the author the ability to style an element with an iconic equivalent | 3 |
| [nav-down](#) | 指定在何處使用箭頭向下導航鍵時進行導航 | 3 |
| [nav-index](#) | 指定一個元素的Tab的順序 | 3 |
| [nav-left](#) | 指定在何處使用左側的箭頭導航鍵進行導航 | 3 |
| [nav-right](#) | 指定在何處使用右側的箭頭導航鍵進行導航 | 3 |
| [nav-up](#) | 指定在何處使用箭頭向上導航鍵時進行導航 | 3 |
| [outline-offset](#) | 外輪廓修飾并繪制超出邊框的邊緣 | 3 |
| [resize](#) | 指定一個元素是否是由用戶調整大小 | 3 |
### 源碼
本文中所用例子源碼參見[https://github.com/waylau/css3-tutorial](https://github.com/waylau/css3-tutorial) 中 `samples` 目錄下的 userinterface.html