zoukankan      html  css  js  c++  java
  • CSS重置

      在css文件的顶部一般会看到下面的样式

      *  {

        margin: 0;
        padding: 0;
      }

      这里的星号代表所有元素,意思是把所有元素的 marginpadding 都重置为 0

      之所以要这么做,是因为要清除浏览器默认的样式,这种做法简单,粗暴,但不推荐

      所以慢慢就衍生出了 reset.css

      一般常用的 reset.css 有 5 种,详见:https://www.cnblogs.com/humin/p/3515547.html

      

      我选择的是上面链接的第一种:Eric Meyer’s “Reset CSS” 2.0

      

    /** * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) * http://cssreset.com */
    
    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,
    hgroup,
    menu,
    nav,
    output,
    ruby,
    section,
    summary,
    time,
    mark,
    audio,
    video {
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 100%;
        font: inherit;
        vertical-align: baseline;
    }
    
    
    /* HTML5 display-role reset for older browsers */
    
    article,
    aside,
    details,
    figcaption,
    figure,
    footer,
    header,
    hgroup,
    menu,
    nav,
    section {
        display: block;
    }
    
    body {
        line-height: 1;
    }
    
    ol,
    ul {
        list-style: none;
    }
    
    blockquote,
    q {
        quotes: none;
    }
    
    blockquote:before,
    blockquote:after,
    q:before,
    q:after {
        content: '';
        content: none;
    }
    
    table {
        border-collapse: collapse;
        border-spacing: 0;
    }

      

      然后我根据自己的需要适当做了一些调整

      ①:删除了这3个属性

        font-size: 100%;

        font: inherit;

        vertical-align: baseline;

      ②:增加了2个属性

        outline:0;

        text-decoration: none;

        text-decoration: underline;

      ③:上面 reset.css 没有给 input和button元素重置margin,padding,outline为0


     
    /** * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) * http://cssreset.com */
    
    
    /* css重置——去除浏览器默认样式 */
    
    a,
    abbr,
    acronym,
    address,
    applet,
    article,
    aside,
    audio,
    b,
    big,
    blockquote,
    body,
    canvas,
    caption,
    center,
    cite,
    code,
    dd,
    del,
    details,
    dfn,
    div,
    dl,
    dt,
    em,
    embed,
    fieldset,
    figcaption,
    figure,
    footer,
    form,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    header,
    hgroup,
    html,
    i,
    iframe,
    img,
    ins,
    kbd,
    label,
    legend,
    li,
    mark,
    menu,
    nav,
    object,
    ol,
    output,
    p,
    pre,
    q,
    ruby,
    s,
    samp,
    section,
    small,
    span,
    strike,
    strong,
    sub,
    summary,
    sup,
    table,
    tbody,
    td,
    tfoot,
    th,
    thead,
    time,
    tr,
    tt,
    u,
    ul,
    var,
    video,
    input,
    button {
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
    }
    
    article,
    aside,
    details,
    figcaption,
    figure,
    footer,
    header,
    hgroup,
    menu,
    nav,
    section {
        display: block;
    }
    
    body {
        line-height: 1;
    }
    
    ol,
    ul {
        list-style: none;
    }
    
    blockquote,
    q {
        quotes: none;
    }
    
    blockquote:after,
    blockquote:before,
    q:after,
    q:before {
        content: '';
        content: none;
    }
    
    table {
        border-collapse: collapse;
        border-spacing: 0;
    }
    
    a {
        text-decoration: none;
    }
    
    a:hover {
        text-decoration: underline;
    }
    
    
    
    
    
    

       

       

  • 相关阅读:
    React Native for Android应用名及图标修改
    如何不使用Navigator空间实现跳转页面?
    ReactNative WebView组件详解
    react-native react-navigation使用
    微信小程序——选择某个区间的数字
    Git分支操作——查看、新建、删除、提交、合并
    Github + Hexo 搭建个人博客
    微信小程序——动态设置swiper的高度
    微信小程序——购物车结算
    解决stackoverflow打开慢的问题
  • 原文地址:https://www.cnblogs.com/tu-0718/p/9955061.html
Copyright © 2011-2022 走看看