我的项目中有一个div,点击此div旁边的按钮可以放大和缩小此div。呈现一种可以放大和缩小的浮动效果。
实现效果之后有一个问题就是:此div里面包含了一个table,每次点放大之后再点缩小,table里的前三行会略有增大一些。其他行的大小都不变。
就是说每次点放大,缩小前三行都会自动增高一些,里面的字体,行高度都会增大一些。狂点按钮之后,整个div里只能看到这前三行了。
请问高手,这是怎么回事?有人知道吗?这是我用的javascript代码
function changWH(obj1, obj2) {//div id a agrandir et icon a changer
indexz = parseInt(indexz) + 1;
var winwidth = document.documentElement.offsetWidth; //winwidth=1823 var obj1 = document.getElementById(obj1);
var obj2 = document.getElementById(obj2);
var leftmove = 0;
var defwidth;
if (winwidth > document.getElementById("headall").offsetWidth) {
var widthes = winwidth - document.getElementById("bottomcontent").offsetLeft * 2;
//widthes=999
if (widthes < 1470) {
document.getElementById('bottomcontent').style.left = -document.getElementById('headall').offsetLeft * 0.8 + "px"; leftmove = -document.getElementById('headall').offsetLeft * 0.8;
document.getElementById("bottomcontent").style.width = (winwidth - document.getElementById("bottomcontent").offsetLeft * 2) + "px";
}
else {
document.getElementById("bottomcontent").style.width = "1670px";
document.getElementById('bottomcontent').style.left = -document.getElementById('headall').offsetLeft * 0.8 + "px";
document.getElementById('leftside').style.left = document.getElementById('headall').offsetLeft * 0.8 + "px";
leftmove = -document.getElementById('headall').offsetLeft * 0.8; }
defwidth = document.getElementById("bottomcontent").offsetWidth - 10 + "px";
}
else {
if (winwidth > document.getElementById("leftside").offsetWidth) {
defwidth = winwidth * 0.95 + "px";
}
else {
defwidth = document.getElementById("bottomcontent").offsetWidth - document.getElementById('rightside').offsetWidth - 20 + "px";
}
}
tempwidth = obj1.style.width;
tempheight = obj1.style.height;
temptop = obj1.style.top;
templeft = obj1.style.left;
if (flags != 1) {
with (obj1.style) {
width = tempwidth2
height = tempheight2
left = templeft2
top = temptop2
zIndex = indexz
}
obj2.innerHTML = "Agrandir =>>";
flags = 1;
}
else {
tempwidth2 = tempwidth;
tempheight2 = tempheight;
temptop2 = temptop;
templeft2 = templeft;
with (obj1.style) {
width = defwidth
//height = tempheight2
top = "1"
left = leftmove
zIndex = indexz
}
obj2.innerHTML = "<<= Réduire";
flags = 0;
}
}点击前效果点击后效果
实现效果之后有一个问题就是:此div里面包含了一个table,每次点放大之后再点缩小,table里的前三行会略有增大一些。其他行的大小都不变。
就是说每次点放大,缩小前三行都会自动增高一些,里面的字体,行高度都会增大一些。狂点按钮之后,整个div里只能看到这前三行了。
请问高手,这是怎么回事?有人知道吗?这是我用的javascript代码
function changWH(obj1, obj2) {//div id a agrandir et icon a changer
indexz = parseInt(indexz) + 1;
var winwidth = document.documentElement.offsetWidth; //winwidth=1823 var obj1 = document.getElementById(obj1);
var obj2 = document.getElementById(obj2);
var leftmove = 0;
var defwidth;
if (winwidth > document.getElementById("headall").offsetWidth) {
var widthes = winwidth - document.getElementById("bottomcontent").offsetLeft * 2;
//widthes=999
if (widthes < 1470) {
document.getElementById('bottomcontent').style.left = -document.getElementById('headall').offsetLeft * 0.8 + "px"; leftmove = -document.getElementById('headall').offsetLeft * 0.8;
document.getElementById("bottomcontent").style.width = (winwidth - document.getElementById("bottomcontent").offsetLeft * 2) + "px";
}
else {
document.getElementById("bottomcontent").style.width = "1670px";
document.getElementById('bottomcontent').style.left = -document.getElementById('headall').offsetLeft * 0.8 + "px";
document.getElementById('leftside').style.left = document.getElementById('headall').offsetLeft * 0.8 + "px";
leftmove = -document.getElementById('headall').offsetLeft * 0.8; }
defwidth = document.getElementById("bottomcontent").offsetWidth - 10 + "px";
}
else {
if (winwidth > document.getElementById("leftside").offsetWidth) {
defwidth = winwidth * 0.95 + "px";
}
else {
defwidth = document.getElementById("bottomcontent").offsetWidth - document.getElementById('rightside').offsetWidth - 20 + "px";
}
}
tempwidth = obj1.style.width;
tempheight = obj1.style.height;
temptop = obj1.style.top;
templeft = obj1.style.left;
if (flags != 1) {
with (obj1.style) {
width = tempwidth2
height = tempheight2
left = templeft2
top = temptop2
zIndex = indexz
}
obj2.innerHTML = "Agrandir =>>";
flags = 1;
}
else {
tempwidth2 = tempwidth;
tempheight2 = tempheight;
temptop2 = temptop;
templeft2 = templeft;
with (obj1.style) {
width = defwidth
//height = tempheight2
top = "1"
left = leftmove
zIndex = indexz
}
obj2.innerHTML = "<<= Réduire";
flags = 0;
}
}点击前效果点击后效果
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货