component-传入值圆形百分比展示,.background-image: conic-gradient()

1.效果

2.代码

<template>
     <div class="circle" :style="{ 'background-image': `conic-gradient(#3498db 0 ${fillPercentage}%, transparent ${fillPercentage}% 100%)` }"></div> <!-- 使用动态绑定样式来设置填充效果 -->
</template>
<script>
 data() {
    return {
	  fillPercentage: 25, // 设置默认填充百分比为75%
}
}
</script>
<style>
    .circle {
        width: 200px;
        height: 200px;
        border-radius: 50%;
    }
</style>

数据属性fillPercentage来控制圆形的占比显示,默认值为75%。在圆形元素的样式中,使用动态绑定:style来设置background-image属性,根据fillPercentage的值动态调整填充效果。

3.background-image: conic-gradient()

  background-image: conic-gradient是CSS中的一个属性,用于设置元素的背景图像为圆锥渐变效果。通过使用conic-gradient函数作为背景图像,可以创建具有圆锥渐变色彩的视觉效果。语法如下:

background-image: conic-gradient(<angle> || to <side-or-corner>, <color-stop-list>);

其中:

  • <angle>:指定渐变的起始角度。
  • to <side-or-corner>:指定渐变的方向,可以是to topto rightto bottomto leftto top rightto top leftto bottom rightto bottom left等。
  • <color-stop-list>:定义了颜色和位置的列表,类似于线性渐变中的<color-stop>
.element {
    background-image: conic-gradient(#3498db 0% 30%, transparent 30% 100%);
}

 示例代码表示将.element元素的背景图像设置为从蓝色到透明的圆锥渐变效果,在0%到30%之间为蓝色,30%到100%之间为透明。根据需要调整颜色和位置来创建不同样式的圆锥渐变背景。

  • 12
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值