O'Reilly logo

Responsive Web Design with jQuery by Gilberto Crespo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How percentage gives flexibility to the structure

Some old websites, and even recent ones, that do not care about the flexible structure, still use pixel as the unit of measurement. Pixel provides us greater control of its structure and accuracy. But, nowadays, we no more have control over where the website will be displayed (as we saw in Chapter 1, Exploring Responsive Web Design), which generates the need to build flexible structures where elements may stretch and fit the dimension.

Percentage always works as it is related to the value declared in its parent element. So, if a div tag is of size 50 percent and its parent element has 600 px, the div tag will be of the size 300 px, as the following figure shows:

The same applies to a percentage where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required