Reputation: 512
About the rem unit introduced since CSS3, is it rendered only when a page refreshed? If resizing a web page for responsive testing, will a text, whose font size is defined as the rem unit, also be resized dynamically?
Upvotes: 1
Views: 900
Reputation: 263
The rem size is based on your html font-size. Look at the code below (or this fiddle).
HTML :
<p>
Lorem
</p>
<p>
Ipsum
</p>
<p>
Dolor
</p>
<p>
Sit
</p>
<p>
Amet
</p>
CSS :
html {
font-size: 24px;
}
p:nth-child(1) {
font-size: 1rem;
}
p:nth-child(2) {
font-size: 2rem;
}
p:nth-child(3) {
font-size: 3rem;
}
p:nth-child(4) {
font-size: 4rem;
}
p:nth-child(5) {
font-size: 5rem;
}
@media screen and (max-width: 600px) {
html {
font-size: 12px;
}
}
Upvotes: 0
Reputation: 2141
rem
references to the root font size defined in html
element. So if you change your font-size dynamically the elements will be resized, otherwise not.
Upvotes: 4