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

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

為什么title的值是160,117而不是150,105

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<style type="text/css">

*{

margin: 0 0;

padding: 0 0;

}

div{

width: 400px;

height: 250px;

background: black;

/*margin: 0 auto;*/

text-align: center;

line-height: 250px;

position: absolute;

left: 0;

top: 0;

}

span{

width: 100px;

height: 40px;

background: white;

color: black;

}

</style>

<title></title>

</head>

<body>

<div id="div1">

<span id="span1">按住我拖拽</span>

</div>

<script type="text/javascript">

var fubiaoqian=document.getElementById("div1")

var benshen=document.getElementById("span1")

benshen.style.cursor="pointer"

function tuodong(){

document.onmousemove=function(weizhi){

var weizhi=weizhi||window.weizhi;

var juliX=benshen.offsetLeft

juliY=benshen.offsetTop

fubiaoqian.style.left=weizhi.clientX+"px"

fubiaoqian.style.top=weizhi.clientY+"px"

document.title=juliX+","+juliY

}

}

benshen.onmousedown=tuodong

</script>

</body>

</html>


正在回答

1 回答

因為你用的是span,是行內標簽,所以寬度和高度不是像塊元素那樣是固定的,是根據內容大小改變的,也就是說,你設置的寬度對span不起作用,高度也是,行內元素和塊元素是不一樣的,給span設置高度和寬度沒有意義

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

舉報

0/150
提交
取消

為什么title的值是160,117而不是150,105

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

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

幫助反饋 APP下載

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

公眾號

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