• SVG 渐变边框在 CSS 中的应用


    在这里插入图片描述
    SVG 渐变边框在 CSS 中的应用

    <template>
      <div class="home">
      
        <div class="one">
          <svg width="100%" height="100%">
            <rect x="2" y="2" width="100%" height="100%" fill="none"
              style="width: calc(100% - 4px);height: calc(100% - 4px);" rx="4" stroke="url(#paint0_linear_1_2)"
              stroke-width="4" stroke-linecap="round" />
            <defs>
              <linearGradient id="paint0_linear_1_2" x1="0" y1="0" x2="1" y2="0">
                <stop stop-color="#FFD75A" />
                <stop offset="1" stop-color="#ED424B" />
              </linearGradient>
            </defs>
          </svg>
    
        </div>
    
        <div class="one">
    
          <svg width="100%" height="100%" viewBox="0 0 100% 100%" fill="none" xmlns="http://www.w3.org/2000/svg">
            <rect x="0" y="0" width="100%" height="100%" rx="4" stroke="url(#paint0_linear_1_2)" stroke-linecap="round" />
            <defs>
              <linearGradient id="paint0_linear_1_2" x1="0" y1="0" x2="1" y2="0">
                <stop stop-color="#FFD75A" />
                <stop offset="1" stop-color="#ED424B" />
              </linearGradient>
            </defs>
          </svg>
    
        </div>
    
        <div class="one">
    
          <svg width="100%" height="100%" fill="none" xmlns="http://www.w3.org/2000/svg">
            <rect x="2" y="2" width="100%" height="100%" style="width: calc(100% - 4px);height: calc(100% - 4px);"
              stroke-width="2" rx="16" stroke-linecap="round" stroke="url(#paint0_linear_3269_5233)"
              stroke-dasharray="8 6" />
            <defs>
              <linearGradient id="paint0_linear_3269_5233" x1="0" y1="0" x2="100%" y2="100%" gradientUnits="userSpaceOnUse">
                <stop stop-color="#FFD75A" />
                <stop offset="1" stop-color="#ED424B" />
              </linearGradient>
            </defs>
          </svg>
    
    
        </div>
    
        <div class="one">
    
          <svg width="100%" height="100%" fill="none" xmlns="http://www.w3.org/2000/svg">
    
            <rect class="rect" x="2" y="2" width="100%" height="100%" stroke-width="2" rx="16" stroke-linecap="round"
              stroke="url(#paint0_linear_5234_3269)" stroke-dasharray="8 6" />
            <defs>
              <linearGradient id="paint0_linear_5234_3269" x1="0" y1="0" x2="100%" y2="100%" gradientUnits="userSpaceOnUse">
                <stop stop-color="#00bbff" />
                <stop offset="1" stop-color="red" />
              </linearGradient>
            </defs>
          </svg>
    
    
        </div>
    
      </div>
    </template>
    
    <script>
    
    export default {
      name: 'HomeView',
      data() {
        return {
         
        }
      },
      
    }
    </script>
    
    <style scoped>
    .home {
      width: 100%;
      height: 100%;
    }
    
    .one {
      width: 100px;
      height: 80px;
      display: inline-block;
      margin: 0 10px;
    }
    
    .rect {
      width: calc(100% - 4px);
      height: calc(100% - 4px);
      animation: move .3s infinite linear;
    }
    
    @keyframes move {
      0% {
        stroke-dashoffset: 0;
      }
    
      100% {
        stroke-dashoffset: 14;
      }
    }
    </style>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
  • 相关阅读:
    Python字典全解析:从基础到高级应用
    [Unity3D]用C#在unity里面写一个简单的红绿灯
    Springboot jpa 查询排序Sort,分页Page使用报错
    我用GPT搭建了一个虚拟女友!
    【自然语言处理(NLP)】基于SQuAD的机器阅读理解
    企业运维实践-丢弃手中的 docker build , 使用Kaniko直接在Kubernetes集群或Containerd环境中快速进行构建推送容器镜像
    cgroup version jdk version k8s
    idea安装MyBatisX插件,没有效果
    什么蓝牙耳机久戴不痛?久戴不累耳的蓝牙耳机推荐
    瑞吉外卖(25)- 菜品展示功能开发
  • 原文地址:https://blog.csdn.net/Aa12364567/article/details/136555594