您好,登錄后才能下訂單哦!
當(dāng)拖拽對(duì)象時(shí)定位光標(biāo)。默認(rèn)情況下,光標(biāo)是出現(xiàn)在被拖拽對(duì)象的中間。使用 cursorAt 選項(xiàng)來(lái)指定相對(duì)于 draggable 的另一個(gè) 位置(指定一個(gè)相對(duì)于 top、right、bottom、left 的像素值)。通過(guò)提供一個(gè)帶有有效的 CSS 光標(biāo)值的 cursor 選項(xiàng),來(lái)自 定義光標(biāo)的外觀
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>光標(biāo)樣式</title> <link rel="stylesheet" href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css"> <style> #draggable1,#draggable2,#draggable3,#draggable4,#draggable5,#draggable6{ width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } </style> </head> <body> <div id="draggable1" class="ui-widget-content"> <p>我總是在中間(相對(duì)于鼠標(biāo))</p> </div> <div id="draggable2" class="ui-widget-content"> <p>我的光標(biāo)是在 left -5 和 top -5</p> </div> <div id="draggable3" class="ui-widget-content"> <p>我的光標(biāo)位置只控制了 'top' 值</p> </div> <div id="draggable4" class="ui-widget-content"> <p>我的光標(biāo)位置只控制了 'right' 值</p> </div> <div id="draggable5" class="ui-widget-content"> <p>我的光標(biāo)位置只控制了 'bottom' 值</p> </div> <div id="draggable6" class="ui-widget-content"> <p>我的光標(biāo)位置只控制了 'left' 值</p> </div> <script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js" type="text/javascript" ></script> <script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script> <script> $("#draggable1").draggable({ cursor:"move", cursorAt:{ top:56, left:56 } }); $("#draggable2").draggable({ cursor:"move", cursorAt:{ top:-5, left:-5 } }); $("#draggable3").draggable({ cursor:"move", cursorAt:{ top:0 } }); $("#draggable4").draggable({ cursor:"move", cursorAt:{ right:0 } }); $("#draggable5").draggable({ cursor:"move", cursorAt:{ bottom:0 } }); $("#draggable6").draggable({ cursor:"move", cursorAt:{ left:0 } }); </script> </body> </html>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。