学院首页>网页制作>CSS>CSS滤镜:blur属性

CSS滤镜:blur属性

作者:佚名 来源:不详 添加时间:2006-5-25 18:26:19
虲SSblur?
  先来看一下blur属性的表达式:

  filter:blur(add=add,direction,strength=strength)

  我们看到blur属性有三个参数:add、direction、strength。
  Add参数有两个参数值:true和false。意思是指定图片是否被改变成模糊效果。    Direction参数用来设置模糊的方向。模糊效果是按照顺时针方向进行的。其中0度代表垂直向上,每45度一个单位,默认值是向左的270度。角度方向的对应关系见下表:

 

  Strength参数值只能使用整数来指定,它代表有多少像素的宽度将受到模糊影响。默认值是5像素。
  还是看一个例子吧。

===================

<html>
  <head>
  <title>blur css</title>
  <script>
  function handlechange(obj)
  {
with(obj.filters(0))
{
   if (strength<255)
   {
strength +=2;
direction +=45;
   }
}
  }
  </script>
 </head>

<body>
<p><img id ="img1" src="/edu/files/pic/2006-5/25/0652518261831806.jpg" style="filter:blur(strength=1)"
   onfilterchange="handlechange(this)">
</p>
 </body>
</html>

=====================

看起来是不是有些像万花筒,在这个例子中加入了一些JavaScript的语句,代码如下:

  <html>
   <head>
   <title>blur css</title>
   <script>
   function handlechange(obj)
   //*设置一个循环函数handlechange,对象是obj*//
   { with(obj.filters(0))//*Obj的filter属性*//
    { if (strength<255)//*设置循环条件*//
     { strength +=1;direction +=45;}
    //*每循环一次strength就加1,direction加45度*//        
    }
   }
   </script>
   </head>
   <body>
   <p><img id =“img1” src="/edu/files/pic/2006-5/25/0652518261915767.jpg"”         
     style=“filter:blur(strength=1)”
     onfilterchange=“handlechange(this)”>
   //*导入一幅图片,初始blur属性strength等于1,同时调用onfilterchange函
   数*//
   </p>
    </body>
  </html>

站内搜索