rem formula

FIG amount rem formula:

Get ratio: device size / design dimensions 

For example: the device width dimension 375px, 750px design dimensions, calculated to obtain the ratio of 0.5, the width of a picture element to obtain an amount of design is 100px, 375px actual width of the device on this element is 100 * 0.5 = 50 px.

Therefore:

Set the default value html font-size 0.5px, for convenience of calculation generally calculated in 100-fold, i.e. 50px, as follows:

@media screen and (min-width:375px) {
    html {
        font-size: 50px;
    }
}

As, at this time 1rem = 50px, when writing css disposed on the device 375 to a width of 0.5rem (.5rem equal to the width of the actual device 50px converted to the ui design, i.e. 100px)

img.test_img{
    width : .5rem  
}

 

Guess you like

Origin www.cnblogs.com/jony-it/p/11225143.html
rem