1

此 text-shadow 示例中的文本不会在 IE 11 中显示,但在 FF 和 Chrome 中会显示。

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

根据caniuse.com的说法,自 IE 10 以来,IE 已经完全支持 text-shadow。有没有办法改变 CSS 使其在 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;
}
4

2 回答 2

2

发生这种情况是因为 IE 希望您在文本上有一个基色。您还可以使用text-shadow来定义基色。

您可以更改它,以便您还定义color属性。

#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现在分配给该color属性的位置。

为什么会这样?

好吧,我不确定这是否发生在以前版本的 IE 中。但是,正如您在MS 文本阴影生成器中看到的那样,chrome 和 FF 不支持一个属性;传播距离。这可能表明 IE 没有使用与 chrome 和 FF 相同的方法。
然而,在给某物添加阴影之前先给出基色似乎是合乎逻辑的。

补充说明

我建议也让-webkit- 支持一切。例如transition,在 chrome 中仅支持-webkit-transition.

jsFiddle

于 2013-11-29T13:17:57.310 回答
0

这是一个非常棘手的问题,您可能找不到任何答案,如果您打开一个简单的 html 文件到 ie10 或 ie11,这将显示您所有的文本阴影,但您感兴趣的应用程序不支持文本阴影,即使它显示一些错误意味着文本阴影文本下的红线。

您只需要为此更改元标记...使用这些

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> // ie supports
<meta name="viewport" content="width=device-width, initial-scale=1">// for responsive
于 2014-12-05T06:52:35.927 回答