分享

div style常用属性大全 (二)

 甘孜雄鹰 2011-09-22
div style常用属性大全 (二)
2011年08月15日 星期一 上午 10:10

33、border:设置DIV的边框样式。

例:

 

<div style="border:dotted 2px black; background-color:Yellow; width:100px;height:100px;">

</div>

 

 

 

说明:border后跟边框的样式、宽度、颜色等属性。还可以用以下属性分别设置。

34、border-width:设置边框的宽度。

35、border-color:设置边框的颜色。

36、border-style:设置边框的样式。

例:

 

代码
1<label style="font-size:14px;">选择样式:</label>
2
3<select id="bstyle" onchange="document.getElementById('tdd').style.
4
5borderStyle=this.options[this.selectedIndex].text;">
6
7<option selected="selected">none</option>
8
9<option>dashed</option>
10
11<option>dotted</option>
12
13<option>groove</option>
14
15<option>hidden</option>
16
17<option>inset</option>
18
19<option>outset</option>
20
21<option>ridge</option>
22
23<option>double</option>
24
25<option>solid</option>
26
27</select>
28
29<div id="tdd" style="border-style:none; border-width:5px; border-color:Black; width:100px;height:100px;background-color:Yellow;">
30
31</div>

 

 

 

说明:border是对四个边框同时进行设置。也可以单独对某一边或几个边进行设置,此时用以下属性:

 

border-top:设置上边框样式。

37、border-bottom:设置下边框样式。

38、border-left:设置左边框样式。

39、border-right:设置右边框样式。

说明:某一边框的某一样式也可单独设置,以上边框为例可以用:border-top-style、border-top-width、border-top-color来分别设置,由于使用各border相同,所以不在举例说明。

40、display:设置显示属性。其值有block、none。

41、float:设置DIV在页面上的流向,其值有left(靠左显示)、right(靠右显示)、none。

50、background:设置DIV的背景样式。

例:

 

1<div style="width:600px;height:200px; background:yellow url(mw3.jpg) repeat scroll; 
2
3overflow:auto">
4
5<div style="width:2px;height:1000px;"></div>
6
7</div>

 

 

说明:background后可直接跟背景的颜色、背景图片、平铺方式等样式。也可以用以下属性分别设置。

51、background-color:设置背景颜色。

52、background-attachment:背景图像的附加方式,其值有scroll、fixed。

53、background-image:指定使有的背景图片。

54、background-repeat:背景图象的平铺方式。其值有no-repeat(不平铺)、repeat(两个方向平铺)、

repeat-x(水平方向平铺)、repeat-y(垂直方向平铺)。

55、background-position:在DIV中定位背景位置。其值有top bottom left right的不同组合。也可以以用坐标

指定具体的位置。

例:

 

1<div style="background-color:Yellow; background-image:url(mw3.jpg); background-position:right bottom; background-attachment:scroll; width:600px;height:200px;">
2
3</div>
4

 

 

 

 

 

二、一些特殊效果:

1、cursor:设置DIV上光标的样式。

2、clip:设置剪辑矩形。

例:

 

代码
<div style="font:16px 宋体;width:600px;height:200px; cursor:help; clip:rect(0px 100px 20px 0px); line-height:20px; overflow:auto;background-color:Yellow;position:absolute">

div样式测式how areyou.

</div>

 

 

说明:clip:rect(top right bottom left);设置上下左右的距离,但此时要把position指定为absolute。看以上效果。

3、filter:滤镜效果。

例:

 

代码
<div style="width:450px;height:200px;background-color:Blue;">

<div id=”tdiv” style="background-color:Yellow; filter:alpha(opacity=50);opacity:0.5;

float:left; width:200px;height:200px;" >

</div>

<div style="background-color:Yellow; width:200px;height:200px;float:left;">

</div>

</div>

 

 

说明:设置透明度:opacity:value (FF专用,value的取值为0至1之间的小数),filter:alpha(opacity=value)(IE专用,value取值:0至100)。

如果要有JavaScript改变DIV的透明度可用下面的方法:

FF中:document.getElementById('tdiv').style.opacity='0.9';

IE中:document.getElementById('tdiv').style.filter='alpha(opacity=90)';

 

* 以下是滤镜综合的例子,将以下代码复制到一个网页文件中就可看到其效果,所以就不要加以说明了。

例:

 

<style type="text/css">

       #paneldiv div

       {

          background-Color:yellow;

          height:200px;

          width:200px;

       }

</style>

<div id="paneldiv" style="width:230px;height:2300px;

background-color:Blue;">

    <div style="filter:alpha(opacity=0,finishopacity=80,style=1,

startx=10,starty=10,FinishX=100, FinishY=100);opacity:0.5;">

     alpha效果:<br />

    </div>

    <div style="filter:blur(add=1,direction=100,strength=5);">

              blur效果:<br />

              add为1代表字有阴影,0代表字全部模糊。

              abcdefghijklmnopqrstuvwxyz

    </div>

    <div style="filter:chroma(color='#ff0000')" onclick="this.style.backgroundColor='#ff0000'" ondblclick="this.style.backgroundColor='black';">

       chroma效果:<br />

       原为黄色,单击变成红色变成透明,双击变成黑色。

    </div>

    <div style="filter:FlipH;">

              fliph效果:<br />

              ABCDEFGH<br />

              IJKLMNOP<br />

              此属性在设置宽高后有效

    </div>

    <div style="filter:FlipV;">

              flipv效果:<br />

              ABCDEFGH<br />

              IJKLMNOP<br />

              此属性在设置宽高后有效

    </div>

    <div style="filter:gray;">

         gray效果:<br />

         abcdefghijklmn

    </div>

    <div style="filter:invert; text-transform:uppercase;color:Red;">

               invert效果:<br />

               背景色变成相反颜色,如黑变成白。

    </div>

    <div style="filter:wave(add=0,freq=3,lightstrength=20,phase=3,strength=10)">

               wave效果:<br />

               Add:一般为1,或0。(0表示上下波浪) 

             Freq:变形值。(指定多少个波浪)

             LightStrength:变形百分比。(变形后的阴影。)

             Phase:角度变形百分比。(弯曲的角度)  Strength:变形强度。(数值越大,DIV变形就越大。)

    </div>

    <div style="filter:Xray">

         xray效果:<br />

         sfasdfasdfasdfsadf

    </div>

<div style="filter: progid:DXImageTransform.Microsoft.Gradient

(GradientType=0, StartColorStr='#B5CCFA', EndColorStr='#ffffff');">

       progid:dximagetransform.microsoft.gradient效果:<br />

       endendendendendendendendendend

    </div>

</div>

<div style="filter:DropShadow(color='#666666',OffX='3',OffY='3',

Positive='1');width:200px;height:200px;">

         dropshadow效果:<br />

         此效果只有在不设置背景色时有效,这时Color指定的将成为背景色。此时背上的字将是清晰的。positive为0时color将成为背景色,为1时color只是文本投影的颜色。

    </div>

<div style="filter:Glow(color='#0000ff',strength='3');

width:100px;height:100px;">

         glow效果:<br />

         strength的光的强度0--100;此时不能设DIV的背景色。

    </div>

<div style="filter:mask(color='ff0000'); width:100px;

height:100px;text-transform:uppercase;color:black; ">

           mask效果:<br />

           没有明显效果,不能设背景色。

   </div>

   <div style="filter:shadow(color='0000ff',direction='100');

width:100px;height:100px;">

               shadow效果:<br />

               abcdefghijklmn

   </div>

   <div style="filter:Xray;width:100px;height:100px;

background-color:red;">

       xray效果:<br />

      sfasdfasdfasdfsadf

   </div>

   <div style="filter: progid:DXImageTransform.Microsoft.Gradient

(GradientType=100, StartColorStr='#B5CCFA', EndColorStr='#ffffff');width:100px;height:100px;">

        渐变效果。

        endendendendendendendendendend

  </div>

  <div style="filter:progid:dXImageTransform.Microsoft.Pixelate(maxsquare=5);width:100px;height:100px;">

               lsksalsslalalalalalalal

 </div>

 <div style="filter:alpha(opacity=100, finishOpacity=0,style=2);

width:100px; height:100px;background-color:Yellow;">

</div>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约