Text Shadow in IE 11 not working

前端 未结 2 577
执念已碎
执念已碎 2020-12-22 04:07

The text in this example of text-shadow doesn\'t display in IE 11, but does in FF & Chrome.

http://codepen.io/maxnguyen/pen/

According to caniuse.com IE

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 04:50

    This happens because IE wants you to have a base color on the text. You also use text-shadow to define the base color.

    You can change this so you also define the color property.

    #flash {
      display: inline-block;
      text-shadow: #bbb 0 0 1px, #fff 0 -1px 2px, #fff 0 -3px 2px, rgba(0,0,0,0.8) 0 30px 25px;
      transition: margin-left 0.3s cubic-bezier(0, 1, 0, 1);
    }
    

    Changes to

    #flash {
      display: inline-block;
      color: #bbb;
      text-shadow: #fff 0 -1px 2px, #fff 0 -3px 2px, rgba(0,0,0,0.8) 0 30px 25px;
      transition: margin-left 0.3s cubic-bezier(0, 1, 0, 1);
    }
    

    Where your first text-shadow is now assigned to the color property.

    Why does this happen?

    Well i'm not certain if this happend in the previous versions of IE. However as you can see at the MS text-shadow generator there is a property that is not supported by chrome and FF; spread distance. This might suggest that IE does not use the same methods as chrome and FF do.
    However it seems logic to give a base color before give a shadow to something.

    Addition notes

    I suggest to also let -webkit- support everything. For example transition in chrome is only supported by -webkit-transition.

    jsFiddle

提交回复
热议问题