Simple adaptation of front-end PC Edition

Source: Internet
Author: User

We all know that adaptation to the front-end PC version is a challenge, most of which are media queries. However, if you have time for companies to do not want to perform media queries, the screen is displayed on full screen regardless of the size of the screen. I am thinking about why I don't need REM to adapt to the PC.

I made a simple JS adaptation based on the design diagram 1920.

<SCRIPT type = "text/JavaScript"> var winwidth = document.doc umentelement. offsetwidth | document. Body. offsetwidth winwidth = winwidth <1366? 1366: winwidth var ohtml = document. getelementsbytagname ('html') [0] ohtml. style. fontsize = 100 * winwidth/1920 + 'px 'window. addeventlistener ('resize', function () {var winwidth = document.doc umentelement. offsetwidth | document. body. offsetwidth winwidth = winwidth <1400? 1400: winwidth var ohtml = Document. getelementsbytagname ('html') [0] ohtml. style. fontsize = 100 * winwidth/1920 + 'px '}) </SCRIPT>

Put this JS script in the root directory, which is also included in index.html. The size we have measured is divided by 100 to convert the bit REM.

By the way, my project is built by vue. Of course, if it is a vue-cli3, It will be placed in the index file under the Public file.

This completes simple PC-end adaptation.

Simple adaptation of front-end PC Edition

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.