如何获取显示:table-cell支持在IE?任何纯javascript或jQuery解决方法? [英] How to get display:table-cell support in IE? any pure javascript or jQuery workaround?
问题描述
如何在IE中获取 display:table-cell
支持?我需要最轻的解决方案。
How to get display:table-cell
support in IE? I need lightest solution.
推荐答案
最快的解决方案
<!--[if lte IE 7 ]><table><td><![endif]-->
<div>
<!-- your markup here -->
</div>
<!--[if lte IE 7 ]></td></table><![endif]-->
对于单个页面可以接受,但一定要避免大规模使用
Could be acceptable for a single page, but definitely to avoid in a large scale
否则你可以详细指定你为什么要尝试定义一个display:table-cell。如果这在某种程度上与获取文本的垂直对齐有关,你可以看看这段代码。
otherwise you could specify in detail why are you trying to define a display: table-cell. if this is somewhat related to obtain a vertical alignment of text you could take a look to this snippet of code
http://jsfiddle.net/fcalderan/985e4/
-
编辑
-- edit (after comment)
如果您想获得底部对齐,您还可以将 position:relative
设置为图像容器然后 position:absolute;底部:0;
到图像
If you wish to obtain a bottom alignment you could also set position : relative
to the image container and then position: absolute; bottom: 0;
to the image
-
编辑2(注释后)
-- edit 2 (after comment)
我们还在等待你的代码。无论如何,结果css将是
We are still waiting your code. Anyway the resulting css will be
#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 */
}
这篇关于如何获取显示:table-cell支持在IE?任何纯javascript或jQuery解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!