css默认样式重置
@charset "utf-8"; *{margin:0;padding:0;} img {border:none; display:block;} em,i{ font-style:normal;} body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td, font { padding: 0; margin: 0; font-family:"微软雅黑"; } table { border-collapse: collapse; border-spacing: 0;} h1, h2, h3, h4, h5, h6 { font-weight: normal; font-size: 100%; } ol, ul, li, dl, dt, dd { list-style: none; } input, button, textarea, checkbox, select, radio, form { vertical-align: top; } a{ color: #000; text-decoration: none; } a:link, a:visited { text-decoration: none; } a:hover{color:#cd0200;text-decoration:underline} input[type="submit"], input[type="reset"], input[type="button"], button { -webkit-appearance: none; } html,body{height:100%}
移动端适配 rem.js
/** * YDUI 可伸缩布局方案 * rem计算方式:设计图尺寸px / 100 = 实际rem 例: 100px = 1rem */ !function (window) { /* 设计图文档宽度 */ var docWidth = 750; var doc = window.document, docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; var recalc = (function refreshRem () { var clientWidth = docEl.getBoundingClientRect().width; /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 */ docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 5 + 'px'; return refreshRem; })(); /* 添加倍屏标识,安卓为1 */ docEl.setAttribute('data-dpr', window.navigator.appVersion.match(/iphone/gi) ? window.devicePixelRatio : 1); if (/iP(hone|od|ad)/.test(window.navigator.userAgent)) { /* 添加IOS标识 */ doc.documentElement.classList.add('ios'); /* IOS8以上给html添加hairline样式,以便特殊处理 */ if (parseInt(window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/)[1], 10) >= 8) doc.documentElement.classList.add('hairline'); } if (!doc.addEventListener) return; window.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); }(window);
附:一个比较全面的css样式重置 https://blog.csdn.net/qq_35630674/article/details/96484307
来源:https://www.cnblogs.com/xiaoyu2/p/12447354.html