1、网站变灰色

用的是css的filter功能

代码片段
9 行
html {
   filter: grayscale(100%);//IE浏览器
  -webkit-filter: grayscale(100%);//谷歌浏览器
  -moz-filter: grayscale(100%);//火狐
  -ms-filter: grayscale(100%);
  -o-filter: grayscale(100%);
  filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  -webkit-filter: grayscale(1);//谷歌浏览器
}

注:有一些网站FLASH动画的颜色不能被CSS滤镜控制,可以在FLASH代码的和之间插入:

代码片段
2 行
<param value="false" name="menu"/>
<param value="opaque" name="wmode"/>

2、DIV可编辑

在div中添加

代码片段
1 行
contentEditable="true"

属性

代码片段
3 行
<div id="div1" contentEditable="true"  ></div>  

<div id="div2" contentEditable="true" ></div>

3、禁止选择、复制功能

代码片段
1 行
unselectable="on" onselectstart="return false;"
代码片段
3 行
<div unselectable="on" onselectstart="return false;">
你想复制我?门儿都没有!!!
</div>

4、form表单文字两端对齐

5、input声音录入按钮

代码片段
2 行
<!-- 添加 x-webkit-speech 属性就可以了。 -->
<input type="text" class="box" name="s" id="s" class="inputText" placeholder="输入关键词"  x-webkit-speech>

6、设置placeholder文字颜色

代码片段
12 行
::-webkit-input-placeholder { /* WebKit browsers */
    color:    #999;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    color:    #999;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    color:    #999;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    color:    #999;
}

7、CSS3多张背景图片

background-image属性

代码片段
11 行
div{
	background:url("1.jpg") 0 0 no-repeat,
             url("2.jpg") 200px 0 no-repeat,
             url("3.jpg") 400px 201px no-repeat;
}
/* 也可以这么写 */
div{
	background-image:url("1.jpg"),url("2.jpg"),url("3.jpg");
	background-repeat: no-repeat, no-repeat, no-repeat;  
	background-position: 0 0, 200px 0, 400px 201px; 
}

8、CSS选中状态修改

9、上传按钮美化

css input[type=file] 样式美化,input上传按钮美化

10、CSS :after 和:before选择器

11、透明度

代码片段
11 行
div{
    opacity: .9; 
    filter:alpha(opacity=90)
}
/* IE7和IE6中opacity是没有用的,在IE6中DIV透明的方法一般用filter; */
.div{
    opacity: 0; 
    cursor:pointer; 
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
}

12、超出长度显示省略号

单行文本显示...

多行文本显示....

代码片段
1 行
(主要属性-webkit-line-clamp)

跨浏览器兼容的方案
设置相对定位的容器高度,用包含省略号(…)的元素模拟实现

13、阴影效果

代码片段
4 行
/* 盒子阴影 */
box-shadow: 2px 2px 10px 4px #333333;	
/* 文子阴影 */
text-shadow: 1px 1px 0px #fff;

14、CSS强制换行和不换行

15、CSS 圆角

代码片段
9 行
-moz-border-radius: 15px;
border-radius: 15px;
/* (注意:border-radius必须放在最后声明,否则可能会失效。) */

/* 另外,早期版本Firefox的单个圆角的语句,与标准语法略有不同。 */
-moz-border-radius-topleft(标准语法:border-top-left-radius)
-moz-border-radius-topright(标准语法:border-top-right-radius)
-moz-border-radius-bottomleft(标准语法:border-bottom-left-radius)
-moz-border-radius-bottomright(标准语法:border-bottom-right-radius)

16、css3弹性布局flex

Flex 布局教程:实例篇

17、textarea禁止拖动

代码片段
9 行
resize: none; //禁止拖动
/* 
以下是resize属性的的各个取值:
    none:用户不能操纵机制调节元素的尺寸;
    both:用户可以调节元素的宽度和高度;
    horizontal:用户可以调节元素的宽度;
    vertical:让用户可以调节元素的高度;
    inherit:默认继承。
*/

18、div垂直居中的方法总结

css的div垂直居中的几种方法
css固定宽高DIV内部元素垂直居中的方法

19、CSS3的一些前缀总结

代码片段
4 行
-webkit  为Chrome/Safari
-moz  为Firefox
-ms   为IE
-o 为Opera

20、css3的box-sizing

给了两个并排带边框的div百分比宽度,假如不用box-sizing,边框的宽度会在行内显示。
用box-sizing:border-box,可以去除边框的占位,

代码片段
1 行
语法:box-sizing: content-box|border-box|inherit;

21、模糊遮罩效率,模糊滤镜效果

代码片段
5 行
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-o-filter: blur(3px);
-ms-filter: blur(3px);
filter: blur(3px);

22、渐变效果

默认渐变是从上往下

代码片段
5 行
background:#ed4a60; 
background: -webkit-linear-gradient(#ed5a5e, #ed3a61);
background: -o-linear-gradient(#ed5a5e, #ed3a61); 
 background: -moz-linear-gradient(#ed5a5e, #ed3a61); 
background: linear-gradient(#ed5a5e, #ed3a61);

前面加一个参数,right,left,bottom,top等,就可以指定渐变方向:

代码片段
4 行
background:-moz-linear-gradient(left,#ace,#f96);/*Mozilla*/
background:-webkit-gradient(linear,0 50%,100% 50%,from(#ace),to(#f96));/*Old gradient for webkit*/
background:-webkit-linear-gradient(left,#ace,#f96);/*new gradient for Webkit*/
background:-o-linear-gradient(left,#ace,#f96); /*Opera11*/

还可以从左上角开始渐变left top,right top(右上角)以此类推,

代码片段
3 行
background: -moz-linear-gradient(left top, #ace, #f96);
background: -webkit-linear-gradient(left top, #ace, #f96);
background: -o-linear-gradient(left top, #ace, #f96);

另外还可以指定渐变角度,这个角度是一个由水平线与渐变线产生的的角度,逆时针方向。
因此,使用0deg将产生一个左到右横向梯度,
而90度将创建一个从底部到顶部的垂直渐变。

代码片段
11 行
background: -moz-linear-gradient(<angle>, #ace, #f96);
background: -webkit-gradient(<type>,<angle>, from(#ace), to(#f96));//老的写法
background: -webkit-linear-gradient(<angle>, #ace, #f96);
background: -o-linear-gradient(<angle>, #ace, #f96);

.deg45 {
  background: -moz-linear-gradient(45deg, #ace, #f96);
  background: -webkit-gradient(linear,0 100%,100% 0%,from(#ace),to(#f96));
  background: -webkit-linear-gradient(45deg, #ace, #f96);
  background: -o-linear-gradient(45deg, #ace, #f96);
}

参考文档
http://www.haorooms.com/post/css_common
http://www.qdfuns.com/notes/47654/f26eaa6148a3de8e8055bb6327b82055.html