CSS3 User Interface
CSS3 User Interface
In CSS3, several new user interface features have been added to adjust element sizes, box sizes, and outer borders.
In this chapter, you will learn about the following user interface properties:
- resize
- box-sizing
- outline-offset
Browser support
The numbers in the table indicate the first browser version that supports this property.
A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.
| property | |||||
|---|---|---|---|---|---|
| resize | 4.0 | 79.0 | 5.0 | ||
| 4.0 -moz- | 4.0 | 15.0 | |||
| box-sizing | 10.0 | ||||
| 4.0 -webkit- | 8.0 | 29.0 | |||
| 2.0 -moz- | 5.1 | ||||
| 3.1 -webkit- | 9.5 | ||||
| outline-offset | 4.0 | 15.0 | 5.0 | ||
| 4.0 -moz- | 4.0 | 9.5 |
CSS3 Resizing
In CSS3, the resize property specifies whether an element should be resizable by the user.
This div element is resizable by the user. (in Firefox 4+, Chrome, and Safari)
The CSS code is as follows:
Example
Specify the size of a div element by the user:
div
{
resize:
both
;
overflow:
auto
;
}
Try it »
CSS3 Box Sizing
The box-sizing property allows you to define the exact way content fits into an area.
Example
Specify two bordered boxes side by side:
div
{
box-sizing:
border-box
; -
moz-box-sizing:
border-box
;
/*
Firefox
*/
width:
50
%
;
float:
left
;
}
Try it »
CSS3 Outline Offset
The outline-offset property offsets the outline and draws it beyond the border edge.
There are two differences between an outline and a border:
- An outline does not take up space
- An outline may be non-rectangular
This div has an outline 15 pixels outside the border.
The CSS code is as follows:
Example
Specify an outline 15 pixels outside the border edge:
div
{
border:
2
px
solid
black
;
outline:
2
px
solid
red
;
outline-offset:
15
px
;
}
Try it »
New User Interface Features
| property | Description | CSS |
|---|---|---|
| appearance | Allows you to make an element look like a standard user interface element | 3 |
| box-sizing | Allows you to define certain elements in a way that fits an area | 3 |
| icon | Provides authors with the ability to set an element as an icon equivalent. | 3 |
| nav-down | Specifies where to navigate when the down arrow navigation key is used | 3 |
| nav-index | Specifies the tab order of an element | 3 |
| nav-left | Specifies where to navigate when the left arrow navigation key is used | 3 |
| nav-right | Specifies where to navigate when the right arrow navigation key is used | 3 |
| nav-up | Specifies where to navigate when the up arrow navigation key is used | 3 |
| outline-offset | Offsets the outline and draws it beyond the border edge | 3 |
| resize | Specifies whether an element is resizable by the user | 3 |