• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
midnight_96
博客园    首页    新随笔    联系   管理    订阅  订阅

各大站初始化CSS代码

  • 初始化的意义:不同浏览器对一些初始的样式定义各有不同,为效果尽可能在所有浏览器效果统一,所以这一步是必不可少的。

新浪官网

    
        body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0;} 
        body{background:#fff;color:#333;font-size:12px; margin-top:5px;font-family:"SimSun","宋体","Arial Narrow";} 

        ul,ol{list-style-type:none;} 
        select,input,img,select{vertical-align:middle;} 

        a{text-decoration:none;} 
        a:link{color:#009;} 
        a:visited{color:#800080;} 
        a:hover,a:active,a:focus{color:#c00;text-decoration:underline;}
    

淘宝官网

    
        body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; } 
        body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; } 
        h1, h2, h3, h4, h5, h6{ font-size:100%; } 
        address, cite, dfn, em, var { font-style:normal; } 
        code, kbd, pre, samp { font-family:couriernew, courier, monospace; } 
        small{ font-size:12px; } 
        ul, ol { list-style:none; } 
        a { text-decoration:none; } 
        a:hover { text-decoration:underline; } 
        sup { vertical-align:text-top; } 
        sub{ vertical-align:text-bottom; } 
        legend { color:#000; } 
        fieldset, img { border:0; } 
        button, input, select, textarea { font-size:100%; } 
        table { border-collapse:collapse; border-spacing:0; }
    

网易官网

    
        html {overflow-y:scroll;} 
        body {margin:0; padding:29px00; font:12px"\5B8B\4F53",sans-serif;background:#ffffff;} 
        div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,blockquote,p{padding:0; margin:0;} 
        table,td,tr,th{font-size:12px;} 
        li{list-style-type:none;} 
        img{vertical-align:top;border:0;} 
        ol,ul {list-style:none;} 
        h1,h2,h3,h4,h5,h6{font-size:12px; font-weight:normal;} 
        address,cite,code,em,th {font-weight:normal; font-style:normal;}
    

腾讯QQ官网

    
        body,ol,ul,h1,h2,h3,h4,h5,h6,p,th,td,dl,dd,form,fieldset,legend,input,textarea,select{margin:0;padding:0} 
        body{font:12px"宋体","Arial Narrow",HELVETICA;background:#fff;-webkit-text-size-adjust:100%;} 
        a{color:#2d374b;text-decoration:none} 
        a:hover{color:#cd0200;text-decoration:underline} 
        em{font-style:normal} 
        li{list-style:none} 
        img{border:0;vertical-align:middle} 
        table{border-collapse:collapse;border-spacing:0} 
        p{word-wrap:break-word}
    

个人常用的~

    
        /* 清除内外边距 */
        body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */
        dl, dt, dd, ul, ol, li, /* list elements 列表元素 */
        pre, /* text formatting elements 文本格式元素 */
        fieldset, lengend, button, input, textarea, /* form elements 表单元素 */
        th, td { /* table elements 表格元素 */
            margin: 0;
            padding: 0;
        }

        /* 设置默认字体 */
        body,
        button, input, select, textarea { /* for ie */
            font: 12px/1 Tahoma, Helvetica, Arial, "宋体", sans-serif;
            font: 12px/1 Tahoma, Helvetica, Arial, "Microsoft YaHei", sans-serif; /* 用 ascii 字符表示,使得在任何编码下都无问题 */
        }

        h1 { font-size: 18px; /* 18px / 12px = 1.5 */ }
        h2 { font-size: 16px; }
        h3 { font-size: 14px; }
        h4, h5, h6 { font-size: 100%; }

        address, cite, dfn, em, var { font-style: normal; } /* 将斜体扶正 */
        code, kbd, pre, samp, tt { font-family: "Courier New", Courier, monospace; } /* 统一等宽字体 */
        small { font-size: 12px; } /* 小于 12px 的中文很难阅读,让 small 正常化 */

        /* 重置列表元素 */
        ul, ol { list-style: none; }

        /* 重置文本格式元素 */
        a { text-decoration: none; color: black;  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}
        a:hover { text-decoration: none; }

        abbr[title], acronym[title] { /* 注:1.ie6 不支持 abbr; 2.这里用了属性选择符,ie6 下无效果 */
            border-bottom: 1px dotted;
            cursor: help;
        }

        q:before, q:after { content: ''; }

        /* 重置表单元素 */
        legend { color: #000; } /* for ie6 */
        fieldset, img { border: none; } /* img 搭车:让链接里的 img 无边框 */
        /* 注:optgroup 无法扶正 */
        button, input, select, textarea {
            font-size: 100%; /* 使得表单元素在 ie 下能继承字体大小 */
            outline: none;
        }

        /* 重置表格元素 */
        table {
            border-collapse: collapse;
            border-spacing: 0;
            border: none;
        }
        tr,td{
            border: none;
        }
        /* 重置 hr */
        hr {
            border: none;
            height: 1px;
        }

        /* 让非ie浏览器默认也显示垂直滚动条,防止因滚动条引起的闪烁 */
        html { overflow-y: scroll; }
    
posted @ 2018-09-21 00:00  midnight丶dd  阅读(82)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3