样式重置 移动端适配
程序员文章站
2022-08-06 11:40:49
css默认样式重置 1 @charset "utf-8"; 2 img {border:none; display:block;} 3 em,i{ font-style:normal;} 4 body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, ......
css默认样式重置
1 @charset "utf-8"; 2 img {border:none; display:block;} 3 em,i{ font-style:normal;} 4 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:"微软雅黑"; } 5 table { border-collapse: collapse; border-spacing: 0;} 6 h1, h2, h3, h4, h5, h6 { font-weight: normal; font-size: 100%; } 7 ol, ul, li, dl, dt, dd { list-style: none; } 8 input, button, textarea, checkbox, select, radio, form { vertical-align: top; } 9 a{ color: #000; text-decoration: none; } 10 a:link, a:visited { text-decoration: none; } 11 a:hover{color:#cd0200;text-decoration:underline} 12 .hongred{ color:#f00;} 13 .blank { height: 0.5rem; font-size: 0; line-height: 0; clear: both; overflow: hidden; } 14 input[type="submit"], input[type="reset"], input[type="button"], button { 15 -webkit-appearance: none; 16 }
移动端适配 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样式重置