DIV布局和放大
2016-02-20 08:56
495 查看
题目:当鼠标略过某个区块的时候,该区块会放大,并且其他的区块仍然固定不动
布局:
注:绝对布局和float浮动不能混用
布局:
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>三个div放大问题</title> <style> *{ margin:0; padding:0; } div{ position:absolute; margin:0 auto; } #top{ width:100px; height:250px; background:pink; } #bottom{ top:260px; width:100px; height:250px; background:cornflowerblue; } #right{ left:110px; width:300px; height:510px; background:greenyellow; } </style> </head> <body> <div> <div id="top"></div> <div id="bottom"></div> <div id="right"></div> </div> </body> <script> function zoom(id,x,y){ var obj=document.getElementById(id);//得到对象 var dw=obj.clientWidth;//获取宽度 var dh=obj.clientHeight;//获取高度 obj.onmouseover=function(){//鼠标移上函数 this.style.width=dw*x+'px';//宽度改变 this.style.height=dh*y+'px';//高度改变 4000 this.style.zIndex=1;//设置Z轴优先 } obj.onmouseout=function(){//鼠标移开函数 this.style.width="";//恢复默认值 this.style.height=""; this.style.zIndex=""; } } zoom("top",1.25,1.25);//调用放大函数 zoom("bottom",1.25,1.25); zoom("right",1.25,1.25); </script> </html>
注:绝对布局和float浮动不能混用
相关文章推荐
- Extjs4.0 最新最全视频教程
- Javascript中toFixed方法的改进
- Web布局连载——两栏固定布局(五)
- 5个常见可用性错误和解决方案
- [div+css]晒晒最新制作专题推广页模板
- [css] line-height 百分比单位和数值单位的区别
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表
- 10条影响CSS渲染速度的写法与使用建议第1/3页
- BS项目中的CSS架构_仅加载自己需要的CSS
- 很不错的 CSS Hack 又学了一招
- 发一个css比较清爽的写法
- CSS expression控制图片自动缩放效果代码[兼容 IE,Firefox]
- css布局网页水平居中常用方法
- CSS经典技巧十则第1/2页
- css 兼容性问题this.style.cursor=''hand''
- IE6不能正常解析CSS文件问题的解决方法及原因分析
- 欲练CSS ,必先解决IE的一些细节分析
- CSS文字截取功能实现代码
- 支持IE6 IE7 Firefox 的纯CSS的下拉菜单