<v:group ID="group1" style="position:relative;WIDTH:200px;HEIGHT:200px;" coordsize = "2000,2000">
<v:rect style="WIDTH:2000px;HEIGHT:2000px" fillcolor="#99cccc">
<v:shadow on="t" type="single" color="silver" offset="5pt,5pt">
</v:rect>
<v:oval style="position:relative;top:100;left:100;width:1000;height:1000;z-index:7;" fillcolor="red" strokeColor="red"/>
<v:rect style="position:relative;top:500;left:300;width:1000;height:1000;z-index:8;" fillcolor="blue" strokeColor="blue"/>
<v:line from="200,200" to="1000,1700" style="z-index:9" fillcolor="yellow" strokeColor="yellow" strokeWeight=2pt/>
</v:group>
相信如果你看懂了上面的代码,对 Group 一定理解了。上面使用了一个和Group一样大小的 Rect 作为 Group的边框,然后加上阴影渲染。用MSDN的一个很有意思的例子再看看 Group 的重要用法:( 改变滚动条的值,右边的图片会相应的旋转)
<script language="VBScript" type="text/javascript">
</script>
该例子中,那张图片完全是用VML画出来的,动态改变 Group 的 Rotation 属性就可以实现整个 Group 里面的对象旋转。
VML的这个功能很有用,模版,顾名思义,它可以减少书写代码的量,又使的代码可读性提高。在理解VML模版的时候,可以和 HTML 的 CSS 一样理解,它是定义好的一种形状,下次使用的时候直接声明 type 属性就可以了。看看下面的例子:
<v:shapetype id="arrowUP" coordsize="6 6"> <!--三角形 向上-->
<v:path v="m 3,0 l 0,6,6,6,3,0 x e" />
</v:shapetype>
<v:shapetype id="arrowDown" coordsize="6 6"> <!--三角形 向下-->
<v:path v="m 0,0 l 3,6,6,0,0,0 x e" />
</v:shapetype>
定义好上面的模版后,以后就可以直接调用了:
<v:shape type="#arrowUP" style="position:relative;width:50;height:50"/>
<v:shape type="#arrowDown" style="position:relative;width:50;height:50"/>
<v:shape fillcolor=blue type="#arrowDown" style="position:relative;width:80;height:80" />
不知道大家有没有注意到,VML里面对“,”使用不强制的,你可以使用 coordsize="6,6" 也可以使用 coordsize="6 6" ,效果是一样的。