(借地方存个帖子)急:请教一个vml中文字摆放位置的问题

来源:互联网 发布:淘宝上怎么凑单 编辑:程序博客网 时间:2024/04/30 15:44

我需要在rect中放置文字,但下列代码中文字无法放置道rect中。
请大家帮我看看出错在哪。我试了下 该group中的coordsize为100,100 就可以实现了。但我其他已画好的图形都用到这个group,不可能更改它的coordsize,还有没有什么其他办法解决?

<html xmlns:v>
<STYLE>
v/:*{behavior:url(#default#VML);} //声明变量v为VML对象
</STYLE>
<body>
<v:Group id=grouphjm style="Z-INDEX:10;LEFT:0px;POSITION:relative;TOP:0px; WIDTH:400px;HEIGHT:400px;"
  coordsize="100,-100" coordorigin="50 -50" >
<!--X轴-->
<v:Line style="Z-INDEX:3" from="-30,0" to="30,0" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<!--Y轴-->
<v:Line style="Z-INDEX:8" from="0,-20" to="0,20" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<v:roundrect style='left:-20;top:-20;width:18;height:10;' fillcolor="red">
<v:textbox>
<a href="http://www.msdn.com/"> Click here</a>
</v:textbox>
</v:roundrect>
</v:Group>
</body>

---------

 

加入insert参数,然后自己设置一下位置,搞定..... 程序修改如下:

<html xmlns:v>
<STYLE>
v/:*{behavior:url(#default#VML);} //声明变量v为VML对象
</STYLE>
<body>
<v:Group id=grouphjm style="Z-INDEX:10;LEFT:0px;POSITION:relative;TOP:0px; WIDTH:400px;HEIGHT:400px;"
  coordsize="100,-100" coordorigin="50 -50" >
<!--X轴-->
<v:Line style="Z-INDEX:3" from="-30,0" to="30,0" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<!--Y轴-->
<v:Line style="Z-INDEX:8" from="0,-20" to="0,20" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<v:roundrect style='left:-20;top:-20;width:18;height:10;' fillcolor="red">
<v:textbox inset="0px,-40px,0px,0px">
<a href="http://www.msdn.com/"><font size=2>Click here</font></a>
</v:textbox>
</v:roundrect>
</v:Group>
</body>

----------------------------

不是很明白你的意思,是不是这样啊...... 直接保存为html打开来看效果

<script>
  function AddFont(){
    obj_TextRect=document.createElement("v:rect")
 obj_TextRect.id="bguest"
    obj_TextRect.style.left=10  
    obj_TextRect.style.top=10   
    obj_TextRect.style.height=10
    obj_TextRect.style.width=20

    obj_TextBox=document.createElement("v:textbox")
    obj_TextBox.inset="10px,-30px,20px,0px"
 obj_TextBox.innerText="test"
    obj_TextRect.appendChild(obj_TextBox)
// alert(obj_TextBox.value)
    document.all.grouphjm.appendChild(obj_TextRect)
  }
</script>

<html xmlns:v>
<STYLE>
v/:*{behavior:url(#default#VML);} //声明变量v为VML对象
</STYLE>
<body>
<input type="button" value="AddFont" onclick="AddFont()">
<v:Group id=grouphjm style="Z-INDEX:10;LEFT:0px;POSITION:relative;TOP:0px; WIDTH:400px;HEIGHT:400px;"
  coordsize="100,-100" coordorigin="50 -50" >
<!--X轴-->
<v:Line style="Z-INDEX:3" from="-30,0" to="30,0" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<!--Y轴-->
<v:Line style="Z-INDEX:8" from="0,-20" to="0,20" strokecolor="blue" strokeweight="1pt">
<v:stroke endarrow="classic" dashstyle="dashdot">
</v:stroke>
</v:Line>
<v:roundrect style='left:-20;top:-20;width:18;height:10;' fillcolor="red">
<v:textbox inset="0px,-40px,0px,0px">
<a href="http://www.msdn.com/"><font size=2>Click here</font></a>
</v:textbox>
</v:roundrect>
</v:Group>
</body>
</html>

------------------------------

我试了下: inset中的四个参数中分别是:left、top、width和height
再次谢谢 bguest(bguest)!

原创粉丝点击