语法:<shadow> = inset? && <length>{2,4} && <color>?
注释:问号表示可选参数;{2,4}表示最少2个参数最多4个;
当length =
2时,代表position x 和position y的值;
当length = 3时,代表position x, position y,
blur;
当length = 4时,代表position x, position y, blur,
spread;
example:
当length = 2时:
element { width: 300px; height: 192px; background-color: #C14343; position: relative; box-shadow: 18px 14px 0px 0px #914E60; }
当length = 3时:
element { width: 300px; height: 192px; background-color: #C14343; position: relative; box-shadow: 18px 14px 5px 0px #914E60; }
当length = 4时:
element { width: 300px; height: 192px; background-color: #C14343; position: relative; box-shadow: 18px 14px 5px 8px #914E60; }
当使用inset属性时:
element{ border:5px solid blue; border-radius: 20px; background-color:orange; width: 144px; height: 144px; box-shadow: rgba(0,0,0,0.4) 10px 10px inset; }
浏览器的支持:
box-shadow // ie, firefox, chrome, opera
-webkit-box-shadow //chrome, opera
-moz-box-shadow //都不支持
推荐box-shadow generator: https://developer.mozilla.org/en-US/docs/Web/CSS/Tools/Box-shadow_generator
参考文献:http://www.w3.org/TR/css3-background/