码迷,mamicode.com
首页 > Web开发 > 详细

css 笔记

时间:2016-01-25 22:52:32      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

css 笔记

第一种:常用的全局CSS属性设置    //参考大型网站,如凤凰网
(1)清除所有的标记的内外边距
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0}
(2)项目符号
ul,ol,li{list-style:none;}
(3)全局字体颜色设置
body{font-size:12px;color:#444;}
(4)常用标题的设置
h1,h2,h3,h4,h5,h6{font-size:100%}
h1{padding:11px 0 0; margin-bottom:4px;font:normal 20px/30px 黑体;text-align:center;}
h2 { padding:6px 0 0; margin-bottom:4px; font:normal 20px/30px 黑体; text-align:center; }
h3{font-size:12px}
h4{font-size:12px;font-weight:normal}

(5)全局链接
a{text-decoration:none;cursor:pointer}
a:link, a:visited {color:#004276}
a:hover{text-decoration:underline;color:#ba2636}
(6)图片
img{border:none;}     ie6 图片有边框,兼容性问题,要去边框

(7)浮动和清除
.float1{float:left;}
.float2{float:right}
.clear{clear:both;}
.blank10{height:10px;clear:both;}   添加空白div  解决 div margin 上下边距会合并,兼容性问题

(8)颜色
.red{color:#FF0000;}
.blue{color:#0000FF;}
.green{color:#00ff00;}

安装IETEST 测试 ie 6 

(1)ie5网页居中 
    IE5下的居中,应该是:body{text-align:center} 加上这个,再在最大的div加{text-align:left;}
    Firefox下的居中,应该是:margin:0px auto;
    
    body{text-align:center;}
    .box{ margin:0 auto; text-align:left;}
    <body>
        <div class="box">
            xx xx xx 
        </div>
    </body>
    
    (2)单行内容垂直中齐
    Div{height:80px;line-height:80px;}
    
    (3)IE中元素浮动时,margin左右加倍的问题
    解决办法:Display:inline;  
    
    
margin:0 auto;  ie6还是不行   问题被 (1)解决


margin 左右边距在Ie6下会加倍,上下边距会合并,兼容性问题
上下边距会合并,在中间加 div{height:10px;}

.div1{width:200px;height:200px;background-color:#0000FF;margin:50px;float:left; display:inline;}  
//第一个div 的 display为行内样式 解决"margin 左右边距在Ie6下会加倍"
.div2{width:200px;height:200px;background-color:#0000FF;margin:50px;float:left;}

<body>
<div class="div1"></div>
<div class="div2"></div>

    (4)实现1px高度的<div>
在IE6下解决办法:overflow:hidden;  //超出1px外的部分全部隐藏掉
<div style="width:100px; height:1px; overflow:hidden;"></div> //超出的部分隐藏掉

 

css 笔记

标签:

原文地址:http://www.cnblogs.com/gyz418/p/5158802.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!