我的项目中有一个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&nbsp;=&gt;&gt;";
            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 = "&lt;&lt;=&nbsp;Réduire";
            flags = 0;
        }
    }点击前效果点击后效果

解决方案 »

  1.   

    代码还没看,先问下LZ,你放大DIV的原理,是怎么处理div里面的内容放大的,是仅仅font-size设置大小吗,有没有其他样式的变化?
      

  2.   

    回复二楼,里面的内容并不放大,只是用js放大了div的宽度,高度是固定的,内容完全没有在代码中放大,但是它会自动自己放大。我要的效果就是不要让它放大
      

  3.   

    仅仅是div的width变大吗?能把你的div里面的table代码贴出来,给我试试吗
      

  4.   

    其实table部分不是我写的,没找到在哪里控制