小知识

1、 CSS选择器优先级

  行内样式(通过Style=""定义) 1000;

  ID选择器 100;

  Class类选择器 10;

  类型选择器 1

  数值越大优先级越高

  例如:

 Style="" 优先级为1000;#wrapper #content {}优先级为 100*2=200; #content.datePosted {}优先级为 100+10=110;div#content {}优先级为 1+100=101

2、页脚居底

 1 html, body {
 2         margin:0;    /* 必要,否则纵向滚动条不会消失 */
 3         height:100%; /* 必要,以便之后给container设置高度百分比 */
 4     }
 5 #wrapper {
 6         min-height:100%; /* 此属性需要doctype的支持,见第一行。 否则不会生效。在IE中,写height:100%就可以工作,但其他浏览器需要设置min-height。*/
 7         position:relative; /* 必要 */
 8     }
 9 #main {
10         padding-bottom:120px;    /* 等于footer的高度 */
11     }
12 #footer {
13         position:absolute; /* 必要 */
14         bottom:5px; /* 必要 */
15     }
View Code

3CSS3圆角

圆角(border-radius)

支持浏览器:IE9、Safari、Chrome、Firefox;(尽量使用最新版本,具体到哪个版本支持亦或不支持请百度)

不支持浏览器:IE6~8;

-moz-border-radius   兼容Firefox浏览器;

-webkit-border-radius   兼容Safari,Chrome浏览器;

对于Opera和IE请使用border-radius;

也就是说要兼容现在的浏览器需要3个属性同时写:border-radius,-moz-border-radius,-webkit-border-radius;如:

border:5px solid #dedede;

border-radius:10px;

-moz-border-radius:10px;

-webkit-border-radius:10px;

4、块元素超长内容变省略号的问题

    overflow: hidden;

    white-space: nowrap;

    -o-text-overflow: ellipsis; /* for Opera */

    text-overflow: ellipsis; /* for IE */

基本通杀所有浏览器了~

认非块的元素,要加上display:block;才有效果哦`,..嗯嗯,别忘了width或者max-width.

posted @ 2013-09-30 14:54  Macaque  阅读(155)  评论(0编辑  收藏  举报