Gradient borders

后端 未结 17 1758
一个人的身影
一个人的身影 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:34

    instead of borders, I would use background gradients and padding. same look, but much easier, more supported.

    a simple example:

    .g {
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.33, rgb(14,173,173)), color-stop(0.67, rgb(0,255,255)));
    background-image: -moz-linear-gradient(center bottom, rgb(14,173,173) 33%, rgb(0,255,255) 67% );
    padding: 2px;
    }
    
    .g > div { background: #fff; }
    bla


    EDIT: You can also leverage the :before selector as @WalterSchwarz pointed out:

    body {
        padding: 20px;
    }
    .circle {
        width: 100%;
        height: 200px;
        background: linear-gradient(to top, #3acfd5 0%, #3a4ed5 100%);
        border-radius: 100%;
        position: relative;
        text-align: center;
        padding: 20px;
        box-sizing: border-box;
    }
    .circle::before {
        border-radius: 100%;
        content: '';
        background-image: linear-gradient(to bottom, #3acfd5 0%, #3a4ed5 100%);
        top: -10px;
        left: -10px;
        bottom: -10px;
        right: -10px;
        position: absolute;
        z-index:-1;
    }

提交回复
热议问题