自定義css reset


  1. 不要盲目相信主流說法,*{margin:0;padding:0}或reset.css使用的margin和padding重置方法。大多數reset.css中的代碼都是不需要的,讓我們來試驗下。
    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}
    body)
      ff:ie:gg:
      可見body的margin:0;是需要的,而padding:0;是不需要的。
    div)
      ff:ie:gg:
      可見div的margin和padding的重置都是不需要的。
    根據以上方法最后整理出一個自己的margin和padding:
    body,dl,dd,ul,ol,h1,h2,h3,h4,h5,h6,pre,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0}
    filedset{padding:0;border:0}
  2. 根據自己的實驗,參考YUI的cssreset整理出自己的reset.css文件,壓縮后體積較原來小了很多。僅供參考:
    /**css reset
     * @author maqunjing
     * @date 2012-7-25
     * */
    
    body, dl, dd, h1, h2, h3, h4, h5, h6, pre, p, blockquote, fieldset, textarea, ol, ul {
        margin: 0
    }
    fieldset, textarea, input, a img {
        border: none
    }
    fieldset, textarea, input, legend, th, td, ol, ul {
        padding: 0
    }
    address, caption, cite, code, dfn, em, strong, th, var, optgroup {
        font-style: normal
    }
    th, strong, optgroup, h1, h2, h3, h4, h5, h6 {
        font-weight: normal
    }
    ol, ul {
        list-style: none
    }
    caption, th {
        text-align: left
    }
    h1, h2, h3, h4, h5, h6, sup, sub {
        font-size: 100%
    }
    input, textarea, select, button, optgroup, option {
        font-family: inherit;
        font-size: inherit;
        font-weight: inherit;
        font-style: inherit
    }
    input, button, textarea, select, optgroup, option {
        *font-size: 100%
    }
    code, kbd, samp {
        font-family: inherit
    }
    table {
        border-collapse: collapse;
        border-spacing: 0
    }
    sup, sub {
        vertical-align: baseline;
    }
    q:before, q:after {
        content: ''
    }
    
    :link, :visited, ins {
        text-decoration: none
    }
    :focus {
        outline: 0
    }

     


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM