學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 電腦硬件知識(shí) > 鍵盤(pán)鼠標(biāo) > js設(shè)置鼠標(biāo)光標(biāo)形狀

js設(shè)置鼠標(biāo)光標(biāo)形狀

時(shí)間: 迪豪910 分享

js設(shè)置鼠標(biāo)光標(biāo)形狀

  鼠標(biāo)的形狀各種各樣,有不同的樣式,你知道怎么在js上設(shè)置嗎?不知道的話,跟著學(xué)習(xí)啦小編一起學(xué)習(xí)吧。

  js 設(shè)置鼠標(biāo)光標(biāo)形狀

auto(default) 默認(rèn)值。瀏覽器根據(jù)當(dāng)前情況自動(dòng)確定鼠標(biāo)光標(biāo)類型。
col-resize 有左右兩個(gè)箭頭,中間由豎線分隔開(kāi)的光標(biāo)。用于標(biāo)示項(xiàng)目或標(biāo)題欄可以被水平改變尺寸。
crosshair 簡(jiǎn)單的十字線光標(biāo)。
all-scroll 有上下左右四個(gè)箭頭,中間有一個(gè)圓點(diǎn)的光標(biāo)。用于標(biāo)示頁(yè)面可以向上下左右任何方向滾動(dòng)。
move 十字箭頭光標(biāo)。用于標(biāo)示對(duì)象可被移動(dòng)。
help 帶有問(wèn)號(hào)標(biāo)記的箭頭。用于標(biāo)示有幫助信息存在。
no-drop 帶有一個(gè)被斜線貫穿的圓圈的手形光標(biāo)。用于標(biāo)示被拖起的對(duì)象不允許在光標(biāo)的當(dāng)前位置被放下。
not-allowed 禁止標(biāo)記(一個(gè)被斜線貫穿的圓圈)光標(biāo)。用于標(biāo)示請(qǐng)求的操作不允許被執(zhí)行。
pointer(hand) 豎起一只手指的手形光標(biāo)。就像通常用戶將光標(biāo)移到超鏈接上時(shí)那樣。
progress 帶有沙漏標(biāo)記的箭頭光標(biāo)。用于標(biāo)示一個(gè)進(jìn)程正在后臺(tái)運(yùn)行。
row-resize 有上下兩個(gè)箭頭,中間由橫線分隔開(kāi)的光標(biāo)。用于標(biāo)示項(xiàng)目或標(biāo)題欄可以被垂直改變尺寸。
text 用于標(biāo)示可編輯的水平文本的光標(biāo)。通常是大寫(xiě)字母 I 的形狀。
vertical-text 用于標(biāo)示可編輯的垂直文本的光標(biāo)。通常是大寫(xiě)字母 I 旋轉(zhuǎn)90度的形狀。
wait 用于標(biāo)示程序忙用戶需要等待的光標(biāo)。通常是沙漏或手表的形狀。
*-resize 用于標(biāo)示對(duì)象可被改變尺寸方向的箭頭光標(biāo)。
w-resize | s-resize | n-resize | e-resize | ne-resize | sw-resize | se-resize | nw-resize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js 光標(biāo)設(shè)置</title>
</head>
 
<body>
<input type="button" value="auto" onclick=SetCursor("auto") />
<input type="button" value="col-resize" onclick=SetCursor("col-resize") />
<input type="button" value="row-resize" onclick=SetCursor("row-resize") />
<input type="button" value="all-scroll" onclick=SetCursor("all-scroll") />
<input type="button" value="crosshair" onclick=SetCursor("crosshair") />
<input type="button" value="move" onclick=SetCursor("move") />
<input type="button" value="help" onclick=SetCursor("help") />
<input type="button" value="no-drop" onclick=SetCursor("no-drop") />
<input type="button" value="not-allowed" onclick=SetCursor("not-allowed") />
<input type="button" value="pointer" onclick=SetCursor("pointer") />
<input type="button" value="progress" onclick=SetCursor("progress") />
<input type="button" value="text" onclick=SetCursor("text") />
<input type="button" value="vertical-text" onclick=SetCursor("vertical-text") />
<input type="button" value="wait" onclick=SetCursor("wait") />
<input type="button" value="w-resize" onclick=SetCursor("w-resize") />
 
<div id="test" style="width:600px; height:200px; margin: 0 auto; background-color: blue; color:#FFF;">移動(dòng)鼠標(biāo)到此查看效果</div>  
 
 
</body>
 
<script   language="Javascript">  
function SetCursor(str){  
  document.getElementById('test').style.cursor=str;
}  
</script>
 
</html>

1828045