美文网首页
CSS通用样式

CSS通用样式

作者: 轻丨尘 | 来源:发表于2018-02-12 13:31 被阅读0次
    *{ 
        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;}
    /* 定义图片边框,当图片作为链接内容被填充时,会有默认边框出现,重定义掉 */
    img{ 
         border:none;
         vertical-align:baseline;
    }
    a, a:link, a:visited{
         color:#000;
         text-decoration:none;
    }
    a:hover{ 
        color:#000; 
        text-decoration:underline;
    }
    /* 标签属性,textarea,input 强制输入时内容超出时换行,打断 */
    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为单位,实现包括字体大小、元素间距等的自适应,则需要body前加上几行js。因为pc谷歌浏览器调试不支持小于12px,网上很多是以屏幕宽/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";
    

    相关文章

      网友评论

          本文标题:CSS通用样式

          本文链接:https://www.haomeiwen.com/subject/lkprtftx.html