网易笔试题目:三列布局,中间自适应宽度,双飞翼布局,及问题
2016-03-23 18:12
423 查看
<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> .wrap{ width: 100%; } .one{ float: left; width: 100px; margin-right: -100px; background: yellow; min-height: 100px; } .three{ float: right; width: 100px; margin-left: -100px; min-height: 100px; background: green; } .wrap_two{ width: 100%; float: left; } .two{ margin: 0 110px 0 110px; min-height: 100px; background: purple; } </style> </head> <body> <div class="wrap"> <div class="one">第一个</div> <div class="wrap_two"> <div class="two">第二个</div> </div> <div class="three">第三个</div> </div> </body> </html>
思考,首先水平,水平的办法有那么几种,display:inline-block;float,但是这种方法width不生效,所以float方法,双飞翼就是中间宽度为100%,两边六点空,挂上翅膀,两边的翅膀宽度和对中间身体的拉进来的值相等,他们margin的是中间列的父级div也就是wrap_two,中间列在wrap_two内部两边留白之后就是中间的实际宽度。
效果图如下:
但是测试了一下其他的事件,发现
<div class="one">第一个</div> $(".one").click(function(){ alert(); })
这样并不能触发,但是这样是可以触发的:
$(".wrap_two").click(function(){ alert(); })
原因就是wrap_two这个div是100%的,而且元素在one后面,所以z-index比one高,解决办法是在one加上:
position: relative; z-index: 10;
这样就ok了。
相关文章推荐
- MySQL 中的 InnoDB 与 MyISAM
- Linux驱动开发常用调试工具---之内存读写工具devmem和devkmem
- struts2拦截器+过滤器
- 20160323 MakeFile学习整理
- Shiro安全登录框架
- 从客户端(txtContent="<p>1</p>")中检测到有潜在危险的 Request.Form 值
- Spring-Mongo-Data与Mongo3.2集成问题
- 取石子(-)
- [计服15]第5周 授课内容预习
- MVC模式、MVVM模式
- lesscss的使用
- springMVC分析-3
- linux运维记
- Exception starting filter struts2 java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
- Java字符串:String、StringBuilder、StringBuffer区别
- Servlet 中 session 的创建、销毁及监听
- 自旋锁和互斥锁
- sha加密算法
- 静态成员static
- Android控件之Toolbar + DrawerLayout的使用