1. Development environment vue //Install postcss-pxtorem npm i postcss-pxtorem -S 5. Create a new rem folder in the src directory, create a new rem.js, and add the following code: //Base size const baseSize = 37.5 // Set rem function function setRem() { const salepro = document.documentElement.clientWidth / 750 // The current page width is relative to the 750 width. You can modify it according to your needs. // Set the font size of the root node of the page document.documentElement.style.fontSize = (baseSize * Math.min(salepro, 2)) + 'px' } // Initialize setRem() // Reset rem when changing window size window.onresize = function () { setRem() } 6. Create a new .postcssrc.js in the project root directory and add the following code: module.exports = { "plugins": { "postcss-pxtorem": { "rootValue": 37.5, "propList": ["*"] } } }
7. Import in main.js import '@/rem/rem.js' 8. Use it in the vue template and add the following code to css: <style lang="scss" scoped> .about { width: 750px; height: 100vh; box-sizing: border-box; background-color: blue !important; .kk { width: 350px; height: 350px; background-color: red; } } </style> 9. The effect diagram is as follows: 10. This is the end of this sharing. I hope it will be helpful to you. Let us work together to reach the top. The above is the details of how Vue uses rem adaptation. For more information about Vue using rem adaptation, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Detailed tutorial on compiling and installing python3.6 on linux
>>: Detailed explanation of how to enable slow query log in MySQL database
Zero, Background I received a lot of alerts this ...
Connection query: It is the result of connecting ...
Example: tip: This component is based on vue-crop...
When using nginx as a reverse proxy, you can simp...
There are some tags in XHTML that have similar fu...
Table of contents 1. Introduction to SELinux 2. B...
1. Check the MySQL database encoding mysql -u use...
Additional explanation, foreign keys: Do not use ...
Asynchronous replication MySQL replication is asy...
operating system: Win10 Home Edition Install Dock...
1. New and old domain name jump Application scena...
This article introduces how to install the system...
Table of contents 1. What is Ts 2. Basic Grammar ...
1. MYSQL index Index: A data structure that helps...
Introduction Binlog logs, that is, binary log fil...