css扇形课点击

代码如下:

<!DOCTYPE html>
<html>
<head>
<style> 
div#circle
{
width:100px;
height:100px;
overflow:hidden;
transform-origin:100% 100%;

}
#fan{
width:0;	height:0;	border-radius:100px;	border-width:100px;	border-style:solid;	border-color:red transparent transparent transparent;	line-height:99em;	overflow:hidden;	cursor:pointer;	
transform:rotate(-45deg);
}
</style>
</head>
<body>
<div style="width:200px; height:200px; background-color:green; margin:30px">
<div id="circle">
<div id="fan">Hello World</div>
</div></div>
<button onClick="rotate()">旋转</button>
<script>
var deg=0;
function rotate(){
console.log(222)
deg=deg+90;
var circle=document.getElementById("circle");
circle.style.transform ="rotate("+deg+"deg)";
}
</script>
</body>
</html>
 
  
 


猜你喜欢

转载自blog.csdn.net/milijiangjun/article/details/79912882