文/小魔女css
回流必定会触发重绘,重绘不必定触发回流。html
reflow:改变元素在网页中的布局和位置前端
致使回流发生的状况:ios
对应的css属性以下:web
repaint:改变不影响元素。在网页中的位置的元素样式时,根据浏览器新属性从新绘制一次。不会带来从新布局。面试
致使重绘发生的状况:小程序
致使重绘的css属性以下:微信小程序
css文件放前面,js文件放在html和css的后面浏览器
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
复制代码
//使用这个
img {max-width:100%} //最大宽度显示为自身的100%
//不用这个
img {width: 100%} //宽度为外层容器的宽度 图片会被无情地拉伸
复制代码
media screen and (min-width:1000px) {
body{
background:red;
}
}
复制代码
动态计算 js代码缓存
(function (){
const desWid = 640
const winWid = document.documentElement.clientWidth
const oMain = document.getElementById('main')
const ratio = winWid / desWid
if(winWid > desWid) {
oMain.style.width = desWid + 'px'
oMain.style.margin = '0 auto'
return
}
oMain.style.fontSize = ratio*100 + 'px'
} ())
复制代码
任意浏览器的默认字体高都是16px。
transform:scale(0.5)
渐变
<style>
div{
width: 200px;
height: 200px;
position: relative;
background-color: pink;
}
div::after{
content: ' ';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 1px;
background-image:linear-gradient(0deg, transparent 50%, black 50%)
}
</style>
复制代码
<style>
div{
height: 0.25em;
width: 20rem;
background-size: 0.5em 0.5em;
background-image: linear-gradient(45deg, transparent 45%, red 55%, transparent 60%), linear-gradient(135deg, transparent 45%, red 55%, transparent 60%);
background-repeat: repeat-x;
}
</style>
复制代码
document.addEventListener('gesturestart',function(e) { e.preventDefault() })
body { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
在须要禁止的dom加上这句
ontouchstart="return false;"
复制代码
备注: 手机uc浏览器,meta标签的name=browsermode content= application 这样就没法调起长菜单
在权贵主导的世界里想财务自由,你首先得努力变成和他们同样的人,剩下的就交给命运吧!
本文使用 mdnice 排版