我的css笔记

编码 

css文件的编码要和页面的编码一致,在css中指定编码 要在css文件的最前端,如下:

@charset "utf-8"

 

body 定义

*{ margin:0; padding:0; }
body{  font:12px/130% Verdana, Geneva, Arial, Helvetica, sans-serif 宋体; text-align:center; }

链接 a 定义

a:link {color:#666666; text-decoration:none;}
a:visited{color:#666666; text-decoration:none;}
a:hover{color:#000099; text-decoration:underline;}
a:active{color:#000000; text-decoration:none;}

定义 hr

hr {width:96%; height:1px; margin:0px auto; border:none; border-top:1px dashed #969696; margin-top:10px;*margin-bottom:-14px;float:none;*float:left;display:block;}

 

设计图标时常用的字体:

Microsoft YaHei;
 

使用 line-height 垂直居中

 

line-height:24px;  

 

使用固定宽度的容器并且需要一行垂直居中时,使用 line-height 即可(高度与父层容器一致)

清除容器浮动

#main { overflow:hidden; }  

 

不让链接折行

a { white-space:nowrap; }  

上面的设定就能避免链接折行

 

始终让 Firefox 显示滚动条

html { overflow:-moz-scrollbars-vertical; }  
body, html { min-height:101%; }  

 

使块元素水平居中

margin:0 auto;  

其实就是

margin-left: auto; margin-right: auto;  

这个技巧基本上所有的 CSS 教科书都会有说明,别忘记给它加上个宽度。Exploer 下也可以使用

body{ text-align: center; }  

然后定义内层容器

text-align: left;  

恢复。

 

隐藏 Exploer textarea 的滚动条

textarea { overflow:auto; }  

Exploer 默认情况下 textarea 会有垂直滚动条(不要问我为什么).

 

设置打印分页

h2 { page-break-before:always; }  

page-break-before 属性能设置打印网页时的分页。

 

删除链接上的虚线框

a:active, a:focus { outline:none; }  

Firefox 默认会在链接获得焦点(或者点击时)加上条虚线框,使用上面的属性可以删除。

 

min-height

#mrjin { min-height:100px; height:auto !important; height:100px; overflow:visible; }
 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值