简体   繁体   English

如何在边框样式中添加衬垫渐变?

[英]How to add liner gradient into border style?

Here I have a circular badge.在这里,我有一个圆形徽章。 Below is the code for it下面是它的代码

 .center-badge { background: #09a49c; height: 120px; width: 120px; border-radius: 50%; text-align: center; display: flex; justify-content: center; align-items: center; border: 10px solid #f2f2f2; position: absolute; top: -50px; left: -30px; line-height: 16px; }.center-badge p { font-size: 12px; color: var(--white); margin-bottom: 0px; }.center-badge p strong { display: block; font-size: 16px; }
 <div class="center-badge"> <div> <p>Taux </p> <p>codemandeur</p> </div> </div>

Now I have been asked to add border color as a linear-gradient(#fbfbfb, #c5d4dd) .现在我被要求将边框颜色添加为linear-gradient(#fbfbfb, #c5d4dd) But this works only on a background image.但这仅适用于背景图像。 I have added something like this, but it overrides my whole body color.我添加了类似的东西,但它覆盖了我的全身颜色。 Please help me how to fix this请帮我解决这个问题

.center-badge {
    background: #09a49c;
    height: 120px;
    width: 120px;
    border-radius:50%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: -50px;
    left: -30px;
    line-height: 16px;
    border: 10px solid transparent;
    background-image: linear-gradient(#fbfbfb, #c5d4dd);
    background-origin: border-box;
    background-repeat: no-repeat;  
}

I believe the repetitive background is the problem.我相信重复的背景是问题所在。 How to apply this linear gradient as a border如何将此线性渐变应用为边框

I used this on my project.我在我的项目中使用了这个。 It will work.它会起作用的。

.center-badge {
  ...
  background-image: linear-gradient(#09a49c , #09a49c),
                    linear-gradient(to right, #fbfbfb, #c5d4dd);
  background-origin: border-box;
  border: double 0.2em transparent;
  background-origin: border-box;
  background-clip: padding-box, border-box;
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM