説明
- 用 CSS 刻出游標樣式
- 抓取滑鼠位置
- 游標的位置隨著滑鼠移動而改變
範例
#cross
#cross
position: absolute
&:before,&:after
content: ""
display: block
width: 60px
height: 15px
background-color: #fff
position: absolute
left: 50%
top: 50%
transform: translate(-50%,-50%) rotate(45deg)
&:after
transform: translate(-50%,-50%) rotate(-45deg)
window.addEventListener("mousemove", function(evt){
var x=evt.pageX;
var y=evt.pageY;
cross.style.left=x+"px";
cross.style.top=y+"px";
})
Display