Making Better User Interfaces with CSS3

Making Better User Interfaces with CSS3

For far too long to Making Better User Interfaces, we developers have hacked around CSS to get the effects we need in our code. We’ve used JavaScript or server-side code to stripe table rows or put focus and blur effects on our forms. We’ve had to litter our tags with additional class attributes just so we could identify which of our fifty form inputs we want to style.
But no more! CSS3 has some amazing selectors that make some of this work trivial. In case you forgot, a selector is a pattern that you use to help you find elements in the HTML document so you can apply styles to those elements Making Better User Interfaces. We’ll use these new selectors to style a table. Then we’ll take a look at how we can use some other CSS3 features to improve our site’s print style sheets, and we’ll split content into multiple columns. And we can be successful to Making Better User Interfaces.

We’ll look at these CSS features in this chapter for Making Better User Interfaces with CSS3

:nth-of-type [p:nth-of-type(2n+1){color: red;}]

Finds all n elements of a certain type

:first-child [p:first-child{color:blue;}]

Finds the first child element to Making Better User Interfaces

1. In the descriptions that follow, browser support is shown in square brackets using a shorthand code and the minimum supported version number. The codes used are Making Better User Interfaces
C: Google Chrome, F: Firefox,
IE: Internet Explorer,
O: Opera, S: Safari,
IOS: iOS devices with Mobile Safari, and
A: Android Browser.

:nth-child [p:nth-child(2n+1){color: red;} ]

Finds a specific child element counting forward.

:last-child [p:last-child{color:blue;} ]

Finds the last child element.

:nth-last-child [p:nth-last-child(2){color: red;} ]

Finds a specific child element counting backward.

:first-of-type [p:first-of-type{color:blue;}]

Finds the first element of the given type.

:last-of-type [p:last-of-type{color:blue;}]

Finds the last element of the given type.

Column support [#content{ column-count: 2; column-gap: 20px; column-rule: 1px solid #ddccb5;}]

Divides a content area into multiple columns.

:after [span.weight:after { content: "lbs"; color: #bbb; } ]

Used with content to insert content after the specified element.

Media Queries [media="only all and (max-width: 480)" ]

Apply styles based on device settings for Making Better User Interfaces.