有的浏览器会禁止执行脚本,那样就无效了
CSS就不会
<html>
<head>
<title>css圆角效果</title>
<meta http-equiv="content-type" content="text/htmlcharset=gb2312">
<style type="text/css">
div.RoundedCorner{background: #9BD1FA}
b.rtop, b.rbottom{display:blockbackground: #FFFFFF}
b.rtop b, b.rbottom b{display:blockheight: 1pxoverflow: hiddenbackground: #9BD1FA}
b.r1{margin: 0 5px}
b.r2{margin: 0 3px}
b.r3{margin: 0 2px}
b.rtop b.r4, b.rbottom b.r4{margin: 0 1pxheight: 2px}
</style>
</head>
<body>
<div class="RoundedCorner">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
无图片实现圆角框
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div>
<br>
<div class="RoundedCorner">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
<br>无图片实现圆角框<br><br>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div>
</body>
</html>
<script type="text/javascript"><!--$(document).ready(function()
{
$(".show").mousedown(function(e)//e鼠标事件
{
$(this).css("cursor","move")//改变鼠标指针的形状
var offset = $(this).offset()//DIV在页面的位置
var x = e.pageX - offset.left//获得鼠标指针离DIV元素左边界的距离
var y = e.pageY - offset.top//获得鼠标指针离DIV元素上边界的距离
$(document).bind("mousemove",function(ev)//绑定鼠标的移动事件,因为光标在DIV元素外面也要有效果,所以要用doucment的事件,而不用DIV元素的事件
{
$(".show").stop()//加上这个之后
var _x = ev.pageX - x//获得X轴方向移动的值
var _y = ev.pageY - y//获得Y轴方向移动的值
$(".show").animate({left:_x+"px",top:_y+"px"},10)
})
})
$(document).mouseup(function()
{
$(".show").css("cursor","default")
$(this).unbind("mousemove")
})
})
// --></script>