• 初始化css文件


    首先我们需要了解一下为什么需要公共样式(公共样式是为了初始化某些标签的默认值):

     1. 因为浏览器的兼容问题,不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面显示差异。

     2.初始化CSS样式主要是提高编码质量,如果不初始化整个页面做完很糟糕,重复的CSS样式很多。

    一.PC端公共样式

    这里参考的是I'm QQ(https://im.qq.com/index.shtml)的公共样式,其实对比一下其他大型网站的公共样式也类似:

    html,body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;font-family:Helvetica, Tahoma, Arial, "Hiragino Sans GB", "Hiragino Sans GB W3", "Microsoft YaHei", STXihei, STHeiti, Heiti, SimSun, sans-serif; font-size:100%;}
    html,body{color:#333}
    body{background:#fff;overflow-x: hidden;}
    ul,ol,li{ list-style:none;}
    a:link, a:visited{ color:#333; text-decoration:none;}
    a:hover{ color:#12b7f5;}
    img{ border:none;}
    em{ font-style:normal;}
    h1,h2,h3,h4,h5{ font-weight:normal;}
    .clearfloat:after{ content:'.';display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0;}
    .clearfloat{zoom:1;}
    二.移动端公共样式
    之前开发的时候,移动端和PC公用一个css公共样式,不过看到别人分享的移动端公共样式,主要是多了对html5新标签的样式初始化及以下兼容处理,下次可以试一下.
    /*reset*/
    html{-webkit-text-size-adjust:100%;}
    /*reset*/
    html{max-width: 640px;margin:0 auto;}
    article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}
    body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, figure, section, legend, textarea, p, blockquote, th, td, input, select, textarea, button { margin: 0; padding: 0 }
    fieldset, img { border: 0 none }
    body{font:14px/1.4 "Microsoft Yahei",Arial,Helvetica,sans-serif;background-color: #fff;color:#333;max-width: 640px;margin: 0 auto;}
    h1,h2,h3,h4,h5,h6{font-size:100%;font-weight: normal;}
    table{border-collapse:collapse;border-spacing:0}
    ul,ol,dd,dt,dl{list-style-type:none;}
    a{color:#333;text-decoration: none;-webkit-touch-callout: none;-webkit-user-select: none;}
    a,input,select{-webkit-tap-highlight-color: transparent;-webkit-appearance: none;-moz-appearance: none;-webkit-border-radius: 0;}
    
    input,img{border:none;}
    i,em{font-style:normal;}
    :focus{outline: none}
    select{ background: none }
    
    /*iphone6*/
    @media(min-device-375px)and(max-device-667px)and(-webkit-min-device-pixel-ratio:2){body{font-size:14.5px;}}
    /*iphone6plus*/
    @media(min-device-414px) and (max-device-736px) and (-webkit-min-device-pixel-ratio:3){body{font-size:15.5px;}}
    
    /*原子类*/
    .clear { clear: both; }
    .clear:after { display: block; clear: both; visibility: hidden; height: 0; overflow: hidden; content: "."; }
    .fl { float: left; }
    .fr { float: right; }
    .mb10{margin-bottom: 10px;}
    .mt10{margin-top: 10px;}
    /*placeholder css*/
    ::-moz-placeholder{ font-family: "Microsoft YaHei"}              
    ::-webkit-input-placeholder{ font-family: "Microsoft YaHei"}    
    :-ms-input-placeholder{ font-family: "Microsoft YaHei"}
    
    
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, menu, nav, output, ruby, section, summary, time, mark, audio, video, input {
      margin: 0;
      padding: 0;
      border: 0;
      font-size: 100%;
      font-weight: normal;
      vertical-align: baseline;
    }
    
    .divider {
      height: 16px;
      width: 100%;
      background: #f3f5f7;
      border-top: 1px solid rgba(7, 17, 27, 0.1);
      border-bottom: 1px solid rgba(7, 17, 27, 0.1);
    }
    
    
    /* HTML5 display-role reset for older browsers */
    
    article, aside, details, figcaption, figure, footer, header, menu, nav, section {
      display: block;
    }
    
    body {
      line-height: 1;
    }
    
    blockquote, q {
      quotes: none;
    }
    
    blockquote:before, blockquote:after, q:before, q:after {
      content: none;
    }
    
    table {
      border-collapse: collapse;
      border-spacing: 0;
    }
    
    
    /* custom */
    
    a {
      color: #7e8c8d;
      text-decoration: none;
      -webkit-backface-visibility: hidden;
    }
    
    li {
      list-style: none;
    }
    
    ::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }
    
    ::-webkit-scrollbar-track-piece {
      background-color: rgba(0, 0, 0, 0.2);
      -webkit-border-radius: 6px;
    }
    
    ::-webkit-scrollbar-thumb:vertical {
      height: 5px;
      background-color: rgba(125, 125, 125, 0.7);
      -webkit-border-radius: 6px;
    }
    
    ::-webkit-scrollbar-thumb:horizontal {
      width: 5px;
      background-color: rgba(125, 125, 125, 0.7);
      -webkit-border-radius: 6px;
    }
    
    html, body {
      width: 100%;
    }
    
    body {
      -webkit-text-size-adjust: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    
    
    





  • 相关阅读:
    C#中的多态
    反编译工具
    富文本粘贴图片
    [Silverlight入门系列]用TransformToVisual和Transform取得元素绝对位置(Location)
    Silverlight在IIS中的配置
    HubbleDotNet开源全文搜索数据库项目技术详解
    Thank you for choosing Telerik RadRichTextBox
    Asp.net读取AD域信息的方法<转>
    Sharepoint学习笔记—ECMAScript对象模型系列1、ECMAScript对象模型的引入
    SharePoint WebService
  • 原文地址:https://www.cnblogs.com/stella1024/p/7229994.html
Copyright © 2020-2023  润新知