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

前端 未结 3 1829
庸人自扰
庸人自扰 2020-12-10 22:23

How to get display:table-cell support in IE? I need lightest solution.

3条回答
  •  不思量自难忘°
    2020-12-10 23:06

    the fastest (but not clean) solution is to wrap your container by a table inside a conditional comment like so

    
    

    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. 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)

    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

    -- edit 2 (after comment)

    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 */
    }
    

提交回复
热议问题