文本阴影在IE 11不工作 [英] Text Shadow in IE 11 not working

查看:163
本文介绍了文本阴影在IE 11不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文本阴影示例中的文本在IE 11中不显示,但在FF& Chrome。

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

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

根据 caniuse.com 从IE 10开始,IE已经完全支持文本阴影。是否有一种方法可以改变CSS,以便在IE11中工作?

According to caniuse.com IE has had full support for text-shadow since IE 10. Is there a way to alter the CSS so it would work in IE11?

<div id="box">
  <p id="flashlight">
    <span id="flash">MAX</span>
    <span id="light">NGUYEN</span>
  </p>
</div>

CSS:

html {
  overflow: hidden; /*FF fix*/
  height: 100%;
  font-family: Geneva, sans-serif;
  background: hsl(210, 30%, 0%) radial-gradient( hsl(210, 30%, 20%), hsl(210, 30%, 0%));
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  text-align: center;

  display: flex;
  justify-content: center;
  align-items: center;
}

p {
    margin: 0;
}


/* box ------------------------------------------------------ */

#box {
  text-align: center;
  font-size: 3em;
  font-weight: bold;
  -webkit-backface-visibility: hidden; /* fixes flashing */
}


/* flashlight ------------------------------------------------------ */

#flashlight {
  color: hsla(0,0%,0%,0);
  perspective: 80px;
  outline: none;
}


/* flash ------------------------------------------------------ */

#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);
}

#box:hover #flash {
   text-shadow: #111 0 0 1px, rgba(255,255,255,0.1) 0 1px 3px;
  margin-left: 20px;
  transition: margin-left 1s cubic-bezier(0, 0.75, 0, 1);
}


/* light ------------------------------------------------------ */

#light {
  display: inline-block;
  text-shadow: #111 0 0 1px, rgba(255,255,255,0.1) 0 1px 3px;
}

#box:hover #light {
  text-shadow: #fff 0 0 4px, #fcffbb 0 0 20px;
  transform: rotateY(-60deg);
  transition:         transform 0.3s cubic-bezier(0, 0.75, 0, 1), text-shadow 0.1s ease-out;
}


推荐答案

在文本上有一个基本颜色。您还可以使用 text-shadow 定义基本颜色。

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

您可以更改此设置, code> 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);
}

更改为

#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);
}

您的第一个 text-shadow 现在分配给颜色属性。

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

为什么会发生这种情况?

好吧,我不确定这是否发生在以前的IE版本。但是,您可以在 MS文本阴影发电机有一个属性不支持chrome和FF; 传播距离。这可能表明IE不使用与chrome和FF做相同的方法。

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.

添加一个基本颜色注意

我建议也让 -webkit - 支持一切。例如,Chrome中的 transition 只受 -webkit-transition 支持。

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

这篇关于文本阴影在IE 11不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆