I'm Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with HTML, CSS and SVG. To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

my books

Pro CSS3 Animation book coverPro CSS3 Animation, Apress, 2013

my other blogs

Massive Head CanonMassive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New DefaultsThe New Defaults — A Sass color keyword system for designers.

CSSslidyCSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

Crafting A Basic Responsive Page

Making a page with a dynamic layout.

One of the tenents of responsive design is that you can now create different layouts for your site depending to how wide the browser is, dynamically changing the appearance of your pages as the browser is resized.

Let’s say we have a site for the fictional company “Ray’s Flowers”. Most pages in the site feature three div elements (#col1, #col2, and #col3) presented side-by-side for most desktop screens using display: table-cell

This design is fluid, so the columns of text become difficult to read when the browser is less than 1000 pixels wide. The changes in appearance between “wider than 1000px” and “less than 1000px” are minimal, so rather than creating a separate style sheet, we could make the new styles part of our main CSS:

body { margin: 0; font-family: Cambria; } 
h1 { background: #000; margin-top: 0; }
div#col1, div#col2, div#col3 { display: table-cell; padding: 1em; padding-top: 0; }
/* standard CSS rules applicable to everything up to this point */
@media screen and (max-width: 1000px) {
div#col1, div#col2, div#col3 { display: table-row; }
}

Now if the browser is more than 1000px wide, the columns display vertically; less than 1000px, they are horizontal.

Returning to handheld devices, you can even switch the presentation of the page based on the orientation of the device (technically, this could also work on desktop monitors that can be rotated upright or horizontal, as this rule is also supported in the latest desktop versions of browsers);

@media screen and (orientation:portrait) {
 /* appearance rules effective during vertical orientation of the screen */
 }
@media screen and (orientation:landscape) {
 /* appearance rules for horizontal orientation of the screen */
 }

It should be noted that it is also possible to animate the transition between these @media query states (discussed in an upcoming article), or target page size for printing:

@media print and (width: 210mm) {
	/*rules for printing on an A4-size page */
}

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.