【问题标题】:Gradient css borders not showing in internet explorer an firefox在 Internet Explorer 和 Firefox 中未显示渐变 css 边框
【发布时间】:2015-07-01 14:10:12
【问题描述】:

我正在开发一个 wordpress 标题,我想要一个渐变的底部边框,如下图所示。

这在 Crome 中运行良好,但在 IE 或 Firefox 中似乎不起作用。我不太擅长 css,我承认我从其他地方得到了这段代码。如何让渐变边框出现在 IE 和 Firefox 中?

CSS:

.entry-header {
    /* The main titles links as displayed in the articles*/
    color: #F1F1F1;
    display: inline-block;
    transition: all .3s ease;
    font-family: 'Oswald', sans-serif;
    padding-top: 5%;
    background-color: #1F1F1F;
    width: 100%;
    /*The following code defines the linear gradient colors below each header - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    border-top:0px;
    border-right:0px;
    border-left:0px;
    border-bottom: solid transparent;
    border-bottom: 4px;
    -moz-border-image: -moz-linear-gradient(left, #009C61 14.28571429%, #cc0099 28.57142857%, #cc9900 42.85714287%, #cc0033 57.14285716%, #0099cc 71.42857145%, #6600cc 85.71428574%, #66cc00 100%);
    -webkit-border-image: -webkit-linear-gradient(left, #009C61 14.28571429%, #cc0099 28.57142857%, #cc9900 42.85714287%, #cc0033 57.14285716%, #0099cc 71.42857145%, #6600cc 85.71428574%, #66cc00 100%);
    border-image: linear-gradient(to right, #3acfd5 0%, #009C61 14.28571429%, #cc0099 28.57142857%, #cc9900 42.85714287%, #cc0033 57.14285716%, #0099cc 71.42857145%, #6600cc 85.71428574%, #66cc00 100%);
    border-image-slice: 1;
    /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
}

【问题讨论】:

  • 如果你不能让它在 IE 中工作不要惊讶,在 Internet Explorer 中让现代 CSS 工作并不容易。至于让它在 Firefox 和 Chrome 中运行,它看起来应该可以运行。我可以让它在 Chrome 中工作,但 Firefox 似乎不起作用。尝试在 FF 中研究linear gradients。我认为您的 CSS 可能不适合 Firefox。

标签: html wordpress css firefox


【解决方案1】:

Firefox 和 IE 不支持渐变作为边框图像的图像源

另一种设置结果的方法是使用背景图像,并为它们设置不同的剪辑和原点

.header {
  width: 400px;
  height: 70px;
    border-top:0px;
    border-right:0px;
    border-left:0px;
    border-bottom: 4px solid transparent;
    background-image: linear-gradient(#1f1f1f, #1f1f1f), linear-gradient(to right, #3acfd5 0%, #009C61 14.28571429%, #cc0099 28.57142857%, #cc9900 42.85714287%, #cc0033 57.14285716%, #0099cc 71.42857145%, #6600cc 85.71428574%, #66cc00 100%);
    background-origin: content-box, border-box;
    background-clip: content-box, border-box;
}
<div class="header"></div>

使用填充

.header {
  width: 400px;
  height: 70px;
  padding: 40px;
    border-top:0px;
    border-right:0px;
    border-left:0px;
    border-bottom: 4px solid transparent;
    background-image: linear-gradient(#1f1f1f, #1f1f1f), linear-gradient(to right, #3acfd5 0%, #009C61 14.28571429%, #cc0099 28.57142857%, #cc9900 42.85714287%, #cc0033 57.14285716%, #0099cc 71.42857145%, #6600cc 85.71428574%, #66cc00 100%);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
}
<div class="header"></div>

【讨论】:

  • 这行得通。但由于我使用了填充,渐变覆盖了顶部、底部、左侧和右侧。如何在文本上使用填充而不在边框上应用填充?这就是现在的样子:i.imgur.com/XERV9YG.jpg
  • 深色背景可以应用于内容框,就像我一样,也可以应用于填充框。看我的第二个演示
  • 不错的一个!这很有帮助。谢谢
【解决方案2】:

要在 IE 6-9 上使用渐变,您可以使用它。

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000', GradientType=0 );

但它只支持两种颜色。

注意:这个tool,非常适合生成渐变。 (作者:colorzilla)

【讨论】:

  • 谢谢。是否可以使用 SVG 代替 IE 和 Firefox 的全面支持?如果可能的话,我宁愿在渐变中使用所有颜色。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-03
  • 2015-05-13
相关资源
最近更新 更多