About the pc-side rem font settings ., Pc-side rem font settings

Source: Internet
Author: User

About the pc-side rem font settings ., Pc-side rem font settings

1. the content displayed on the screen is in the upper-right corner (content box). The content is definitely located in the content box. in this way, the content is always in the middle of the screen of different sizes and looks normal.

2. long, wide, LEFT, TOP, RIGHT, and BOTTOM all adopt REM, And the FONT-SIZE of HTML is set to 100PX. 1. It is convenient to calculate, and 2. If it is set to 10PX, google will be incompatible. at this time, the FONT-SIZE of the BODY is set to the normal value, 12PX. otherwise, other DOM will inherit the FONT-SIZE of PX of HTML, resulting in huge effect.

3. When the browser window changes, the content SIZE and relative position will also change accordingly. This is achieved by modifying the FONT-SIZE value of HTML in JS:

$ (Window). resize (function () // bind to this event of the window
{
Var whdef = 100/1920; // indicates the design of 1920, which uses the default value of 100PX.
Var wH = window. innerHeight; // The height of the current window
Var wW = window. innerWidth; // The width of the current window
Var rem = wW * whdef; // multiply the default ratio value by the current window width to obtain the corresponding FONT-SIZE value under this width.
(('Html').css ('font-size', rem + "px ");
});

If you adjust the window SIZE, you will find that the FONT-SIZE value of HTML changes, and the DOM set with REM is also changing, because REM is calculated based on the FONT-SIZE value of HTML.

4. If you are on a mobile phone or tablet, you must use REM. Because the browser size is not adjusted on the mobile phone, you can set it once when loading the page.

$ (Function (){

Var whdef = 50/750; // indicates the design of 750, using the default value of 50PX
Var wH = window. innerHeight; // The height of the cell phone window
Var wW = window. innerWidth; // The width of the mobile phone window
Var rem = wW * whdef; // multiply the default ratio value by the current window width to obtain the corresponding FONT-SIZE value under this width.
(('Html').css ('font-size', rem + "px ");

})

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.