简体   繁体   English

如何在IE中获得display:table-cell支持? 任何纯JavaScript或jQuery解决方法?

[英]How to get display:table-cell support in IE? any pure javascript or jQuery workaround?

How to get display:table-cell support in IE? 如何在IE中获得display:table-cell支持? I need lightest solution. 我需要最简单的解决方案。

the fastest (but not clean) solution is to wrap your container by a table inside a conditional comment like so 最快(但不是很干净)的解决方案是将表包装在条件注释中,如表所示

<!--[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 一页可以接受,但绝对可以避免

otherwise you could specify in detail why are you trying to define a display: table-cell. 否则,您可以详细指定为什么要定义显示: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/ http://jsfiddle.net/fcalderan/985e4/

-- edit (after comment) -编辑(评论后)

If you wish to obtain a bottom alignment you could also set position : relative to the image container and then position: absolute; bottom: 0; 如果希望获得底部对齐,还可以设置position : relative对于图像容器,然后position: absolute; bottom: 0; position: absolute; bottom: 0; to the image 对图像

-- edit 2 (after comment) -编辑2(评论后)

We are still waiting your code. 我们仍在等待您的代码。 Anyway the resulting css will be 无论如何,最终的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 */
}

如果您看一下使用display: table-cell不同组合的display: table-cell 站点 ,可以更轻松地选择所需的CSS设置吗?

No versions of Internet Explorer (including IE8) support the property values "inline-table", "run-in", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-row", or "table-row-group". Internet Explorer的任何版本(包括IE8)都不支持属性值“ inline-table”,“ run-in”,“ table”,“ table-caption”,“ table-cell”,“ table-column”,“ table-列组”,“表行”或“表行组”。

This is the note from w3schools 这是来自w3schools的笔记

I think you should try another way. 我认为您应该尝试另一种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM