Mobile web development: rem responsive design and web development rem response

Source: Internet
Author: User

Mobile web development: rem responsive design and web development rem response

I use sass to write css as follows:

1. variable. scss

Define a variable $ base_fontSize in the variable. scss file to set the basic font size (I am using the percentage, that is, multiply the percentage by the default browser font value ).

//font-size$base_fontSize:62.5%;

2. base. scss

In base. introduce the above variable file in scss (Baidu for sass syntax), and set the initial html font value to $ base_fontSize, next, you can change the value of $ base_fontSize to 1 Rem Based on the screen size of the mobile device through media query. In this way, we can be compatible with all the screens of the ultra-small cell phone to the pad. Of course, you can set the percentage of the value of $ base_fontSize each time as needed.

@import 'variable.scss';html {    font-size: $base_fontSize;}@media only screen and (min-width: 481px){    $base_fontSize:$base_fontSize*94%;    html {        font-size: 1rem!important;    }}@media only screen and (min-width: 561px){    $base_fontSize:$base_fontSize*109%;    html {        font-size: 1rem!important;    }}@media only screen and (min-width: 641px){    $base_fontSize:$base_fontSize*125%;    html {        font-size: 1rem!important;    }}

3. Reference The base.css file generated by base.scssin HTML.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.