标签:only 使用 att mit port turn change UNC size
在计算手机端页面的时候, 使用rem和less的方式, 可以方便的设置需要的大小等
在head中添加
<script>
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘,
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
if(clientWidth>=750){
docEl.style.fontSize = ‘100px‘;
}else{
docEl.style.fontSize = 100 * (clientWidth / 750) + ‘px‘;
}
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener(‘DOMContentLoaded‘, recalc, false);
})(document, window);
</script>
cnpm install --save-dev less less-loader
{
test: /\.less$/,
use: [
"style-loader",
"css-loader",
"less-loader"
]
}
cnpm install --save-dev style-loader css-loader
<style scoped lang="less">
</style>
<template>
<div class="hello">
<div class="box">
<p> 哈哈 </p>
</div>
</div>
</template>
<script>
export default {
name: ‘HelloWorld‘,
data () {
return {
msg: ‘Welcome to Your Vue.js App‘
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
/*200 * 300 宽度*/
.box{
width: 200 / 50rem;
height: 300 / 50rem;
background: dodgerblue;
font-size: 16 / 50rem;
}
</style>
标签:only 使用 att mit port turn change UNC size
原文地址:https://www.cnblogs.com/wenbronk/p/9737294.html