I've created a responsive grid and used em as the font-size to make the text resize, but I must not be fully understanding how em's work as there is no resizing of text.
Live site: http://www.rubytuesdaycreative.co.uk/testsite/shop.html
Following Ethan Marcottes book I've set the body font to font-size:100%
and then made by text within the cpation on the page linked above as 2ems - so double the base size... Am I doing it wrong? It doesn't seem to change at all.
http://jsfiddle.net/jm3sK/
In a responsive approach, in which we adjust the font size at set breakpoints, we will often also arbitrarily adjust the width of a container to maintain the right line length. However, with fluid typography, adjustment at specific breakpoints becomes unnecessary.
You can customize the font style to the whole Grid component by overriding the default CSS. This can be achieved by using the appropriate CSS classes for each Grid sections like header, content etc.
An em is a unit of measurement, relative to the size of the font; therefore, in a typeface set at a font-size of 16px, one em is 16px. The em square is the “box” that each glyph is sized relative to. So, at 12 points, the em square is 12 points wide.
I think what you are looking for is @media
queries. Em
is not a magic-bullet unit that will resize based on the browser width. It is a relative unit.
If you want any CSS to change based on the browser width, use @media
queries.
em
s are useful in this case because you only have to change one value (body{font-size}
) to scale all the rest of the page. Because they are relative, not because the the browser changed. You can use these techniques together.
Here is a quick example. Resize the window.
body{font-size:100%;}
i{font-size: 2em;}
@media screen and (min-width: 500px) {
body{font-size: 150%;}
}
@media screen and (min-width: 700px) {
body{font-size: 200%;}
}
The em
unit means the size of the font. It does not depend on browser window width at all.
The vw
unit relates to the window width: it means 1/100 of the viewport width. But it has limited and buggy support in browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With