【问题标题】:CSS - fading gradient border from-toCSS - 从到到的渐变渐变边框
【发布时间】:2020-05-04 12:52:13
【问题描述】:

我想让我的整个 div 部分带有渐变边框。这是我的代码:

.usermanagement {
  -webkit-border-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      from(#fff),
      to(#afd4ec),
      color-stop(0.2, #afd4ec)
    )
    0 0 0 0 repeat repeat;
}

效果正是我想要的,但只针对top:

然后一切都变成浅蓝色并像这样完成:

没有这种褪色效果。我想为该部分的底端制作与顶部相同的效果。怎么可能?

【问题讨论】:

    标签: html css linear-gradients


    【解决方案1】:

    您可以尝试如下。确保正确设置不同的值。

    .box {
      height:50px; /* this need to be a multiple of 10 for the effect to work */
      border-top:   10px solid;
      border-bottom:10px solid;
      background:#f2f2f2;
      border-image:repeating-linear-gradient(#fff 0,red 10px) 10;
    }
    <div class="box"></div>

    你也可以用多个背景来做:

    .box {
      height:50px;
      border-top:10px solid transparent;
      border-bottom:10px solid transparent;
      background:
       linear-gradient(#fff ,red ) top,
       linear-gradient(#fff ,red ) bottom, /* use (red, #fff) here for the opposite effect */
       #f2f2f2;
      background-size:100% 10px;
      background-origin:border-box;
      background-repeat:no-repeat;
    }
    <div class="box"></div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 1970-01-01
      相关资源
      最近更新 更多