javascript - 如何获得显示 :table-cell support in IE? 任何纯 javascript 或 jQuery 解决方法?

标签 javascript jquery css xhtml

如何在 IE 中获得 display:table-cell 支持?我需要最轻的解决方案。

最佳答案

最快(但不干净)的解决方案是将容器包装在条件注释内的表格中,如下所示

<!--[if lte IE 7 ]><table><td><![endif]-->
<div>                   
 <!-- your markup here -->
</div>
<!--[if lte IE 7 ]></td></table><![endif]--> 

对于单个页面来说可以接受,但绝对要避免大规模

否则您可以详细指定为什么要尝试定义显示:表格单元格。如果这与获得文本的垂直对齐方式有些关系,您可以查看这段代码

http://jsfiddle.net/fcalderan/985e4/

-- 编辑(评论后)

如果您希望获得底部对齐方式,您还可以将 position :relative 设置为图像容器,然后设置 position:absolute;底部:0;到图像

-- 编辑2(评论后)

我们仍在等待您的代码。不管怎样,最终的 css 将会是

#imagecontainer {   /* or whatever image container you have */
  position: relative;
}

#imagecontainer img {
  position: absolute;
  bottom : 0;
  left: 50%; 
  margin-left:-n/2px; /* where 'n' is width of your image */
}

关于javascript - 如何获得显示 :table-cell support in IE? 任何纯 javascript 或 jQuery 解决方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4170883/

相关文章:

javascript - 内部网络上的 jQuery ajax (phonegap android)

javascript - 使用 jquery 添加/更新 URL 中的参数

javascript - 第一次单击按钮后图像 slider 卡住

javascript - React Web 应用程序的默认 css 显示值是多少?

javascript - requestAnimationFrame 回调中的参数到底是什么?

javascript - 当我用 mousemove 旋转图像时,我无法获得负 X 度

相当于第一个 :child to target first <p> in div with heading and img preceding? 的 css

c# - 保持 ASP.NET 日历在每月点击时打开

javascript - react : updating parent state from nested children component

javascript - html 视频 javascript 播放方法在移动 Safari 中不起作用