chrome浏览器下dispaly:table-cell下的新表现or新bug

之前看过张鑫旭的博客 

页面重构“鑫三无准则” 之“无宽度”准则:http://www.zhangxinxu.com/wordpress/?p=1152

CSS流体(自适应)布局下宽度分离原则:http://www.zhangxinxu.com/wordpress/?p=1463

我所知道的几种display:table-cell的应用:http://www.zhangxinxu.com/wordpress/?p=1187

在测试table-cell下无宽度准则时,想试试固定高度的无高度准则,发现table-cell下容器的高度会发生奇妙的变化。

容器固定高度和宽度各300px,不设置display属性,结果如下:

1 <div style="width:300px; height:300px; background-color:#06F;">
2     <div style="height:100%; border:#903 solid 10px; padding:10px;">123456</div>
3   </div>

在给子元素设定高度100%,border和padding各10px后,子元素被撑大了,其实际高度是300+20+20=340px。

给子元素添加display:table-cell属性,其余属性不变,结果如下:

1 <div style="width:300px; height:300px; background-color:#06F;display:table-cell;">
2     <div style="height:100%; border:#903 solid 10px; padding:10px;">123456</div>
3   </div>

 

可以看到设置高度为100%后,改变边框宽度和padding值,元素会自动缩小或加大实际内容的高度,确保实际高度+border+padding=设置高度。

PS:仅针对高度有效,测试给子元素添加width:100%属性后,宽度会被撑大,不过依照张鑫旭的宽度分离原则,宽度是设置在父级元素上,所以子元素宽度自适应就行了。

以上测试浏览器:chrome版本 36.0.1985.125

最近在IE8和火狐13和火狐33测试高度被撑大了,是340px,估计是chrome的一个bug

本文地址:http://www.cnblogs.com/wangjiajun/p/4011676.html 

转载于:https://www.cnblogs.com/wangjiajun/p/4011676.html

Google Chrome稳定版发布大版本更,版本号更为36.0.1985.125 m 更信息: Chrome团队很高兴地宣布适用于Windows,Mac和Linux的Chrome 36稳定版发布。Chrome 36.0.1985.125 包含大量的修正和改进,其中包括: 1、丰富的通知改进 2、一个更的隐身模式/访客模式NTP设计 3、增加了一个浏览器崩溃恢复气泡 4、适用于Linux的Chrome应用程序启动器 5、内部核心大量的稳定性和性能的变化 此更包括26安全修补程序。 包括:同源策略绕过SVG等。 像往常一样,我们正在进内部安全工作负责范围的广泛修补程序: 从内部审计的各种修正,模糊测试和其他措施等。 详细更信息: The Chrome Team is excited to announce the promotion of Chrome 36 to the Stable channel for Windows, Mac and Linux. Chrome 36.0.1985.125 contains a number of fixes and improvements, including: Rich Notifications Improvements An Updated Incognito / Guest NTP design The addition of a Browser crash recovery bubble Chrome App Launcher for Linux Lots of under the hood changes for stability and performance Security Fixes and Rewards This update includes 26 security fixes. Below, we highlight fixes that were either contributed by external researchers or particularly interesting. Please see the Chromium security page for more information. [$2000][380885] Medium CVE-2014-3160: Same-Origin-Policy bypass in SVG. Credit to Christian Schneider. As usual, our ongoing internal security work responsible for a wide range of fixes: [393765] CVE-2014-3162: Various fixes from internal audits, fuzzing and other initiatives. Many of the above bugs were detected using AddressSanitizer. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. Matthew Yuan Google Chrome
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值