html - Font Size to Re-size Based on Window Size -


is there simple way make font re-size based on window size?

for example, font bigger on desktop on mobile device. way, users on smaller screen not have font take room.

i tried using "px" "em" , "%" none of them seem work.

the best way have found use little trick coupled media queries. set body element's font-size in px (some people explode use of px font sizes instead of em, personal preference). example:

body{ font-size: 20px; }

i set other elements percentage of body element. if want h1s 30px set them like:

h1 { font-size: 150%; /* (30/20) * 100 = 150 */ }

however, may pertinent have element fixed font size @ screen sizes, example you're using glyph font , want have icons stay particular size alignment purposes. in case use set px height again. example:

.icon { font-size: 15px; }

what means rather having change whole lot of different element's font-sizes @ different screen widths, have change body element in order globally effect % sized elements no fixed px parents. example:

@media (min-width: 992px){     body{         font-size:14px;     } } 

you have 1 element have worry changing. of course method can applied em units if you'd prefer


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -