亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

鼠標放在最左邊的時候,e.pageX為什么是13?

? ? .left div,

? ? .right div {

? ? ? ? width: 300px;

? ? ? ? height: 80px;

? ? ? ? padding: 5px;

? ? ? ? margin: 5px;

? ? ? ? border: 1px solid #ccc;

? ? }

? ??

? ? .left div {

? ? ? ? background: #bbffaa;

? ? }

?

??<h4>測試二</h4>

? ? <div class="left">

? ? ? ? <div class="aaron1">

? ? ? ? ? ? <p>鼠標在綠色區域移動觸發mousemove</p>

? ? ? ? ? ? <p>移動的X位置:</p>

? ? ? ? </div>

? ? </div>

? ? <script type="text/javascript">

? ? //綁定一個mousemove事件

? ? //觸發后修改內容

? ? $(".aaron1").mousemove(function(e) {

? ? ? ? $(this).find('p:last').html('移動的X位置:' + e.pageX)

? ? ? ? // e.pageX是鼠標相對于文檔邊緣(文檔邊緣也就是document的邊緣)的X軸位置

? ? })

? ? </script>


正在回答

4 回答

你把這段初始樣式指令放進去,再將例子里

.left div,

.right div?

的css的padding margin 和border全部設置為0,那么e.pageX 初始值就為0

.left div,

? ? .right div {

? ? ? ? width: 300px;

? ? ? ? height: 80px;

? ? ? ? padding: 0px;

? ? ? ? margin: 0px;

? ? ? ? border: 0px solid #ccc;

? ? }

? ??








body{ margin: 0;padding: 0;font-family: "微軟雅黑";overflow: hidden;}
body,html{-webkit-text-size-adjust: none;width: 100%;height: 100%;}
*{text-decoration: none;list-style: none;}
img{border: 0px;}
ul,li,dl,dd,dt,p,ol,h1,h2,h3,h4,h5{font-size: 12px;font-weight: 100;padding: 0;margin: 0;}
.wrap{margin: 0 auto;}
.fl{float: left;}
.fr{float: right;}
.index{overflow: hidden;}
.clr{clear:both; height:0px; width:100%; font-size:1px; line-height:0px; visibility:hidden; overflow:hidden;}
.pointer{cursor:pointer;}
a,input,button{ outline:none; }
::-moz-focus-inner{border:0px;}
/*a:link {color:#0f0;text-decoration:none;}?
a:visited {color: #FFFF00; text-decoration:none;}?
a:hover {color: #00FF00; text-decoration:underline;}?
a:active {color: #0000FF; text-decoration:underline;}*/
a{color: #000;}
.wrapper{clear: both;width: 100%;}
word-break:break-all /*文字換行*/
/*white-space:nowrap 文字不換行*/

/*默認滾動條樣式修改ie9 google Firefox 等高版本瀏覽器有效*/
/*::selection {background: #D03333;color: white;text-shadow: none;}
::-webkit-scrollbar-track-piece{width:10px;background-color:#f2f2f2}
::-webkit-scrollbar{width:10px;height:6px}
::-webkit-scrollbar-thumb{height:50px;background-color:rgba(0,0,0,.3);}
::-webkit-scrollbar-thumb:hover{background:#cc0000}*/


/*漸變*/
/*background-image: -moz-linear-gradient(top, #8fa1ff, #3757fa);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ff4f02), color-stop(1, #8f2c00)); Saf4+, Chrome?
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c6ff00', endColorstr='#538300', GradientType='0'); IE*/



0 回復 有任何疑惑可以回復我~

不是起始值,是鼠標在相對可視窗口當前位置的值

0 回復 有任何疑惑可以回復我~

e.PageX是獲取當前光標的橫坐標
最左邊是鼠標在綠色區域移動觸發mousemove的X軸的起始值,至于是怎么計算是我也不知道。

以上純屬個人理解


0 回復 有任何疑惑可以回復我~
#1

慕粉2236556370 提問者

應該是body有個默認的margin值,設置成0后,鼠標在最左邊的時候e.PageX為0
2017-03-20 回復 有任何疑惑可以回復我~

e.pageY 、 e.pageX 是指鼠標的XY(水平、垂直方向)位置值


0 回復 有任何疑惑可以回復我~
#1

慕粉2236556370 提問者

那為什么在最左邊的時候是13呢??
2017-03-17 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

鼠標放在最左邊的時候,e.pageX為什么是13?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號