DWQA QuestionsCategory: ProgramHow can wechat applet set the font size of root element and then use REM?
The wolf tooth man of Shengfeng asked 2 months ago

@media only screen and (min-width:320px) {html {font-size:12px;}}
@media only screen and (min-width:375px) {html {font-size:13px;}}
@media only screen and (min-width:412px) {html {font-size:14px;}}

The HTML element has always been set in this way before, and then the REM unit can be used on the page. 1rem corresponds to the font size of the root element, which is very convenient. Now there is no body in the applet. The biggest element is page. I set the media query on page, and then the default font size in the applet changes to the font size in the media query. However, the default font size is not equal to 1rem, which makes me very upset. No matter how to set it, 1rem is 16px (guess). How can I change 1rem to the corresponding font size in media query in the applet?
1 Answers
Muzimao answered 2 months ago

Reset CSS in rpx

The wolf tooth man of Shengfeng replied 2 months ago

Yes, this rpx is very convenient, but I still want to use rem

chenging replied 2 months ago

If you insist on using rem, you can look at the conversion formula between rpx and other units.