Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't em font-size resize on responsive grid?

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/

like image 228
Francesca Avatar asked Oct 15 '12 21:10

Francesca


People also ask

Does font size change in responsive design?

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.

How do I change font size in grid?

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.

What does Font Size 1em mean?

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.


2 Answers

I think what you are looking for is @mediaqueries. 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.

ems 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%;}
}

like image 180
bookcasey Avatar answered Nov 15 '22 21:11

bookcasey


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.

like image 21
Jukka K. Korpela Avatar answered Nov 15 '22 20:11

Jukka K. Korpela