和老师一样的,clientHeight获取图片可视高度,为什么获取到的是整张的高度,效果就成这样了
function SetimgHeight(){
var pictures = g('.picture');
for (var i = 0; i < pictures.length; i++) {
pictures[i].style.marginTop = (-1*pictures[i].clientHeight/2)+'px';
}
}
function SetimgHeight(){
var pictures = g('.picture');
for (var i = 0; i < pictures.length; i++) {
pictures[i].style.marginTop = (-1*pictures[i].clientHeight/2)+'px';
}
}
2017-03-10
举报