Gradient borders

后端 未结 17 1623
一个人的身影
一个人的身影 2020-11-22 03:40

I\'m trying to apply a gradient to a border, I thought it was as simple as doing this:

border-color: -moz-linear-gradient(top, #555555, #111111);
         


        
17条回答
  •  無奈伤痛
    2020-11-22 04:31

    Here's a nice semi cross-browser way to have gradient borders that fade out half way down. Simply by setting the color-stop to rgba(0, 0, 0, 0)

    .fade-out-borders {
    min-height: 200px; /* for example */
    
    -webkit-border-image: -webkit-gradient(linear, 0 0, 0 50%, from(black), to(rgba(0, 0, 0, 0))) 1 100%;
    -webkit-border-image: -webkit-linear-gradient(black, rgba(0, 0, 0, 0) 50%) 1 100%;
    -moz-border-image: -moz-linear-gradient(black, rgba(0, 0, 0, 0) 50%) 1 100%;
    -o-border-image: -o-linear-gradient(black, rgba(0, 0, 0, 0) 50%) 1 100%;
    border-image: linear-gradient(to bottom, black, rgba(0, 0, 0, 0) 50%) 1 100%;
    }
    
    

    Usage explained:

    Formal grammar: linear-gradient(  [  | to  ,]?  [, ]+ )
                                  \---------------------------------/ \----------------------------/
                                    Definition of the gradient line         List of color stops  
    

    More here: https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient

提交回复
热议问题