css3中的阴影怎么写

html-css011

css3中的阴影怎么写,第1张

box-shadow 属性--设置元素阴影

实例:  向 div 元素添加 box-shadow

<!DOCTYPE html>

<html>

<head>

    <style> 

        div{

            width:300px

            height:100px

            background-color:#ff9900

            -moz-box-shadow: 10px 10px 5px #888888 /* 老的 Firefox */

            box-shadow: 10px 10px 5px #888888

        }

    </style>

</head>

<body>

    <div></div>

</body>

</html>

text-shadow 属性 ---设置文字阴影 <!DOCTYPE html>

<html>

<head>

    <style>

   

         h1{

            text-shadow: 5px 5px 5px #FF0000

        }

    </style>

</head>

<body>

    <h1>文本阴影效果!</h1>

</body>

</html>

只有CSS3才zh支持阴影效果,ke可以用如下写法:

.shadow {

-webkit-box-shadow:1px 1px 3px #292929

-moz-box-shadow:1px 1px 3px #292929

box-shadow:1px 1px 3px #292929

}

上面的代码只能在火狐,chromex下能显示,IE系列还是用tu图片吧~~

颜色(color):rgb(0,0,0)

不透明度(opacity):10%

角度(Angle):投影的角度

距离(Distance):阴影的距离。根据角度和距离可以换算出CSS3阴影中的x-offset和y-offet。 x-offset = Distance * cos(180 -Angle) , y-offset = Distance * sin(180 - Angle)

扩展(Spread): 阴影的扩展大小。控制阴影实体颜色和虚化颜色的多少。 Spread * Size = 阴影中实体颜色的大小 。剩下的就是虚化的颜色。CSS3阴影 spread-radius = Spread * Size

大小(Size): 阴影的大小。在CSS3中 blur-radius + spread-radius = Size 即 blur-radius = Size - spread-radius

x-offset: 87 * cos(180°-(- 90°)) = 0px(87=Distance(ps上的距离),-90°=Angle(ps上的角度))

y-offset: 87 * sin(180°- (- 90°)) =-87px(同理,注意是sin,不是cos)

spread-radius: 0*73=0px(0=Spread(ps上的扩展),73=Size(ps上的大小))

blur-radius: 73-0=73px(73=Size(ps上的大小),0=spread-radius(上一行的数据))

color+opacity:rgba(0,0,0,.1) (.1就是10%,就是不透明度)