CSS元素之前和之后的CSS在Edge和IE 11中不起作用

时间:2017-12-08 11:47:01

标签: css internet-explorer microsoft-edge pseudo-element

我遇到问题,使用以下方法显示带有角度侧面的按钮:使用前:和之后:伪元素。它适用于Chrome和Firefox,但不适用于Edge和IE 11。 可能是什么问题?

a { text-decoration: none }
.container { margin: 20px; }
.font-jos {
  font-family: Verdana;
}
.btn-ribbon {
  position: relative;
  display:inline-block;
  padding: 13px 11px;
  background-color: #b46b78;
  color: #fff;
  font-size: 15px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 0;
  border: none;
  margin-left: 20px;
  text-transform: uppercase;
}
.btn-ribbon:before {
    content: "";
    position: absolute;
    top: 0;
    left: -10px;
    display: block;
    width: 0;
    height: 0;
    border-top: 22px solid #b46b78;
    border-bottom: 22px solid #b46b78;
    border-left: 10px solid #fff0;
    z-index: 1;
}
.btn-ribbon:after {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    display: block;
    width: 0;
    height: 0;
    border-top: 22px solid #b46b78;
    border-bottom: 22px solid #b46b78;
    border-right: 10px solid #fff0;
    z-index: 1;
}
<div class="container">
  <a href="#" class="btn font-jos btn-ribbon">Read more</a>
</div>

https://codepen.io/nidus/pen/gXJYLg

1 个答案:

答案 0 :(得分:5)

您需要在CSS #fff0rgba(255, 255, 255, 0)中将transparent更改为border-right: 10px solid transparent;border-left: 10px solid transparent;。它不喜欢颜色的格式化。

IE和Edge似乎不支持这种格式。

这是一个有效的例子:

&#13;
&#13;
a { text-decoration: none }
.container { margin: 20px; }
.font-jos {
  font-family: Verdana;
}
.btn-ribbon {
  position: relative;
  display:inline-block;
  padding: 13px 11px;
  background-color: #b46b78;
  color: #fff;
  font-size: 15px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 0;
  border: none;
  margin-left: 20px;
  text-transform: uppercase;
}
.btn-ribbon:before {
    content: "";
    position: absolute;
    top: 0;
    left: -10px;
    display: block;
    width: 0;
    height: 0;
    border-top: 22px solid #b46b78;
    border-bottom: 22px solid #b46b78;
    border-left: 10px solid transparent;
    z-index: 1;
}
.btn-ribbon:after {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    display: block;
    width: 0;
    height: 0;
    border-top: 22px solid #b46b78;
    border-bottom: 22px solid #b46b78;
    border-right: 10px solid transparent;
    z-index: 1;
}
&#13;
<div class="container">
  <a href="#" class="btn font-jos btn-ribbon">Read more</a>
</div>
&#13;
&#13;
&#13;

相关问题