已采納回答 / 譚譚譚
<!DOCTYPE html><html><meta charset="utf-8"/><head><title>速度</title><style type="text/css"> body{ margin: 0; padding: 0;} .div1{ width:80px; height: 80px; position: relative; background-color: red; left: -80px...
2015-11-03
已采納回答 / 慕男嬸
獲取樣式,有兩種方法:1、dom.style.xxx 這種寫法只能獲取行內樣式 例如 &ylediv style="width:200px"&sty&e="/div&的樣式? ? div.style.width能獲取到是200px,但是沒有出現在style="" 引號中的樣式是獲取不到的2、萬能...
2015-10-26
已采納回答 / 慕男嬸
是的,返回的是字符串,并且這個字符串千奇百怪比如獲取一個200px寬度的div的寬度,返回的就是 "200px"獲取一個line-height是默認值的div的line-height,返回值是 "normal"獲取font-family,返回的是什么,你自己想吧parseInt只能是把帶單位的數字字符串解析成整數。。parseInt('200px') ==> 200pareInt("normal") 會報錯 NaN
2015-10-26
已采納回答 / 慕男嬸
區別是:obj.style.width 是獲取的content區的寬度,并且只能獲取行內樣式;而offsetWidth獲取的是盒子寬度。例如:<div class="d"></div>.d{????width:200px;????height:200px;????border:10px #ccc solid;? ? padding:10px;? ? background:red;}d.offsetWidth = 200(content區寬度) + 10X2(兩邊的padding) ...
2015-10-26