CSS通用樣式

*{ 
    margin:0;padding:0;  outline: 0;  vertical-align: baseline; 
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html,body{ 
    color:#000; 
    background:#fff; 
    font:12px/22px Verdana,Arial,sans-serif,"Times New Roman",思源宋體; 
    width:100%;
    overflow: hidden;
}
input,select,button{ 
     font-size:100%;
     outline:0;
     vertical-align:middle;
     -webkit-appearance: none;
 }
button{
    border: 0;
    background-clip: padding-box;
}
table {
    border-collapse:collapse;
    border-spacing:0;
}
ol,ul,li { list-style:none;}
/* 定義圖片邊框,當(dāng)圖片作為鏈接內(nèi)容被填充時,會有默認(rèn)邊框出現(xiàn),重定義掉 */
img{ 
     border:none;
     vertical-align:baseline;
}
a, a:link, a:visited{
     color:#000;
     text-decoration:none;
}
a:hover{ 
    color:#000; 
    text-decoration:underline;
}
/* 標(biāo)簽屬性,textarea,input 強(qiáng)制輸入時內(nèi)容超出時換行,打斷 */
textarea,input{ 
    word-wrap:break-word; 
    word-break:break-all; 
} 
span,p,div{ 
    word-wrap:break-word;
} 
.lf{ float:left; }
.rt{ float:right; }
.clearfix{ content: ''; display: block; clear: both; }
  • 普通適配:
@media screen and (min-width:321px) and (max-width:375px){
    html{font-size:11px}
}
@media screen and (min-width:376px) and (max-width:414px){
    html{font-size:12px}
}
@media screen and (min-width:415px) and (max-width:639px){
    html{font-size:15px}
}
@media screen and (min-width:640px) and (max-width:719px){
    html{font-size:20px}
}
@media screen and (min-width:720px) and (max-width:749px){
    html{font-size:22.5px}
}
@media screen and (min-width:750px) and (max-width:799px){
    html{font-size:23.5px}
}
@media screen and (min-width:800px){
    html{font-size:25px}
}
  • 精確適配:
    rem為單位,實現(xiàn)包括字體大小、元素間距等的自適應(yīng),則需要body前加上幾行js。因為pc谷歌瀏覽器調(diào)試不支持小于12px,網(wǎng)上很多是以屏幕寬/37,例如:iphone6為例1rem=10px,此處改為/18.75,1rem為20px,iphone6plus為23.52px
var html = document.getElementsByTagName("html")[0];
var w = document.documentElement.clientWidth || document.body.clientWidth;
html.style.fontSize = w/18.75 +"px";
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容