方案一border-image属性实现
<div class="border-image"></div>.border-image { width: 200px; height: 100px; border-radius: 10px; border-image-source: linear-gradient(45deg, gold, deeppink); border-image-slice: 1; border-image-repeat: stretch; }
方案二:border-image + overflow: hidden
<div class="border-image-overflow"></div>.border-image-overflow { position: relative; width: 200px; height: 100px; border-radius: 10px; overflow: hidden; } .border-image-overflow::before { content: ""; position: absolute; width: 200px; height: 100px; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 10px solid; border-image: linear-gradient(45deg, gold, deeppink) 1; }
第三种 *** border-image + clip-path
<div class="border-image-clip-path"></div>.border-image-clip-path { position: relative; width: 200px; height: 100px; border: 10px solid; border-image: linear-gradient(45deg, gold, deeppink) 1; clip-path: inset(0 round 10px); }
以上三种方案可以让css中圆角渐变边框