使用显示时出现问题:表和溢出:隐藏在IE和Firefox中(在Webkit/blink中工作)
Trouble using display: table and overflow: hidden in IE and Firefox (works in Webkit/blink)
JSFiddle : http://jsfiddle.net/h7xvr2t9/2/
我正在尝试实现一种实现一些效果的方法:
- 将 DIV 滑入应隐藏在可见容器下方的位置
- 将文本/图像居中放在链接上以触发幻灯片
.HTML
<div class="outer">
<div class="inner">
<a id="clickerthing" href="#" class="click">click</a>
<div class="hidden">
you can't see me until after the click...
</div>
</div>
</div>
.CSS
div {
border: thin dashed black;
}
.outer {
float: left;
width: 235px;
background-color: red;
}
.inner {
text-align: center;
position: relative;
height: 200px;
overflow: hidden;
display: table;
width: 100%;
}
.click {
display: table-cell;
height: 100%;
width: 100%;
vertical-align: middle;
background-color: yellow;
}
.hidden {
position: absolute;
width: 100%;
height: 100%;
bottom: -200px;
left: 0px;
text-align: left;
background-color: #FFF;
transition: all 0.3s ease-in-out 0s;
}
.clicked {
bottom: 0;
}
当前代码使用 display: table
和 display: table-cell
为链接和 DIV 正确定位内容。问题在于Firefox和IE处理这个问题的方式与Chrome/Safari不同。在前者浏览器中,隐藏的 DIV 始终可见,而在后者中,它是隐藏的并尊重overflow: hidden
CSS。
我的主要问题是:哪个浏览器行为正确?我找不到明确的答案,大多数答案只建议特定于案例的解决方法。
记住...
我注意到在容器周围添加一个包装div 可以随心所欲地隐藏东西,但我仍然不确定为什么...... : http://jsfiddle.net/h7xvr2t9/3/
你可以像这样在没有包装div 的情况下做到这一点。
http://jsfiddle.net/h7xvr2t9/8/
div {
border: thin dashed black;
}
.outer {
float: left;
width: 235px;
background-color: red;
overflow:hidden
}
.inner {
text-align: center;
position: relative;
height: 200px;
display: table;
width: 100%;
}
.click {
display: table-cell;
height: 100%;
width: 100%;
vertical-align: middle;
background-color: yellow;
}
.hidden {
position: absolute;
width: 100%;
height: 100%;
bottom: -200px;
left: 0px;
text-align: left;
background-color: #FFF;
transition: all 0.3s ease-in-out 0s;
}
.clicked {
bottom: 0;
}
相关文章:
- JavaScript调整iFrame大小-适用于Firefox/IE,但不适用于Chrome
- offset()-top-XX在Webkit v Firefox/IE中给出了不同的结果
- 地理编码器仅适用于chrome,不适用于Firefox / IE / android
- 仅限 Firefox/IE - 元素 show() jquery 后冻结的 gif 动画
- JS .animate() 在 Firefox/IE 中不起作用
- 选择在chrome上选择工作,但不是Firefox / IE
- Ajax在Chrome / Safari中提交作品,但不能在Firefox / IE中提交作品
- Jquery代码没有'在firefox/ie上运行不好
- JavaScript split()仅在Firefox/IE中向数组添加额外项
- 网站页脚是不正常的,当我在firefox/IE中测试它,但在Chrome中工作良好
- YouTube API - Firefox/IE返回错误“X不是一个函数”对于任何'玩家.'请求
- Firefox/IE IIS 6不支持在Javascript/HTML中隐藏标签
- Javascript age gate不能在Chrome上工作,在Firefox, IE, Safari上很好
- 用于测量网页DOM的Firefox / IE工具
- preventDefault()对一个多选择,不同的行为在Firefox - IE - Chrome
- SVG网格渲染Chrome,Firefox,IE -错误的线对齐-模糊的线
- event.preventDefault()在Chrome中工作,但在Firefox / IE中不起作用
- Angular应用程序适用于Firefox/IE,但不适用于chrome
- Firefox/IE jQuery is(":hover") not working
- 阅读cookie工作在Firefox/IE,不是Chrome