2个回答
展开全部
我有一个用js 画圆形的效果 估计你改改就可以了,你将下面的代码保持下看看效果:
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> vml </title>
<style>
v\:* {behavior:url(#default#VML);}
body { padding:0px;margin:0px; }
</style>
</head>
<body>
<div style="position:absolute;top:50px;left:50px;">以mousedown为圆心画椭圆(IE ONLY)</div>
<v:oval id="oval1"
strokecolor="green" filled="F"
style="position:absolute;top:-50px;left:-50px;width:5px;height:5px;">
</v:oval>
<div style="position:absolute;top:1500px;left:1500px;width:50px;height:50px;"></div>
<script type="text/javascript">
var ox=0,oy=0,w,h,r,start=0;
document.ondragstart = function(){return false;}
document.onselectstart = function(){return false;}
document.onmousedown = function (){
if(event.x>document.body.clientWidth || event.y>document.body.clientHeight)return;
ox=event.x+document.body.scrollLeft,oy=event.y+document.body.scrollTop;
document.onmousemove = _mousemove;
document.onmouseup = function(){document.onmousemove = null;}
}
_mousemove = function (){
var dx=(ox-event.x-document.body.scrollLeft),dy=oy-event.y-document.body.scrollTop;
if(dx==0 && dy==0)return;
oval1.style.left=(ox-Math.abs(dx))+'px';
oval1.style.top=(oy-Math.abs(dy))+'px';
oval1.style.width=(2*Math.abs(dx))+'px';
oval1.style.height=(2*Math.abs(dy))+'px';
}
</script>
</body>
</html>
<html xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> vml </title>
<style>
v\:* {behavior:url(#default#VML);}
body { padding:0px;margin:0px; }
</style>
</head>
<body>
<div style="position:absolute;top:50px;left:50px;">以mousedown为圆心画椭圆(IE ONLY)</div>
<v:oval id="oval1"
strokecolor="green" filled="F"
style="position:absolute;top:-50px;left:-50px;width:5px;height:5px;">
</v:oval>
<div style="position:absolute;top:1500px;left:1500px;width:50px;height:50px;"></div>
<script type="text/javascript">
var ox=0,oy=0,w,h,r,start=0;
document.ondragstart = function(){return false;}
document.onselectstart = function(){return false;}
document.onmousedown = function (){
if(event.x>document.body.clientWidth || event.y>document.body.clientHeight)return;
ox=event.x+document.body.scrollLeft,oy=event.y+document.body.scrollTop;
document.onmousemove = _mousemove;
document.onmouseup = function(){document.onmousemove = null;}
}
_mousemove = function (){
var dx=(ox-event.x-document.body.scrollLeft),dy=oy-event.y-document.body.scrollTop;
if(dx==0 && dy==0)return;
oval1.style.left=(ox-Math.abs(dx))+'px';
oval1.style.top=(oy-Math.abs(dy))+'px';
oval1.style.width=(2*Math.abs(dx))+'px';
oval1.style.height=(2*Math.abs(dy))+'px';
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询