<body style="background:#333"> <div id="box"> <img id="img1" src="<gtl:url/>/resources/images/21.jpg" onload="this.width=this.offsetWidth>500?500:this.offsetWidth;"/> <img id="img2" src="<gtl:url/>/resources/images/21.jpg" onload="this.width=this.offsetWidth>500?500:this.offsetWidth;"/> <div id="main"> <div id="left-up" class="minDiv left-up"></div> <div id="up" class="minDiv up"></div> <div id="right-up" class="minDiv right-up"></div> <div id="right-down" class="minDiv right-down"></div> <div id="left-down" class="minDiv left-down"></div> <div id="left" class="minDiv left"></div> <div id="right" class="minDiv right"></div> <div id="down" class="minDiv down"></div> </div> </div> <div id="preview"> <img id="img3" class="img3" src="<gtl:url/>/resources/images/21.jpg" onload="this.width=this.offsetWidth>500?500:this.offsetWidth;"/> </div> <script type="text/javascript"> var boxwidth = document.getElementById('box').offsetWidth; var boxheight = document.getElementById('box').offsetHeight; alert(boxwidth); var img1width = document.getElementById("img1").offsetWidth; var img1height = document.getElementById("img1").offsetHeight; if(img1width>500){ boxwidth = 500+"px"; // alert("jmumwfhqjfri:"+pathwidth); boxheight=(500/img1width)*img1height; }else{ boxwidth=img1width; boxheight=img1height; } </script></body>请问大神,我的div长和宽为什么改变不了吶?求解答,谢谢
添加回答
举报
0/150
提交
取消