注:1/4圆,1/2圆(半圆)、3/4圆(270度)的实现都使用到了clip属性,且属性的值必为自身宽度的一半。
效果
-
1/4圆、1/2圆
image.png
270度圆
image.png进度圆/进度条
image.png全部代码如下
<template>
<div class="container-box">
<!-- 1/4圆 、半圆 -->
<div class="square-box-1">
<div class="circle-90-left-top"></div>
<div class="circle-90-right-top"></div>
<div class="circle-90-right-bottom"></div>
<div class="circle-90-bottom-left"></div>
<div class="circle-180"></div>
<div class="circle-180-roate"></div>
</div>
<!-- 3/4圆 -->
<!-- 270度做法1:180+90 -->
<div class="square-box-2">
<div class="circle-180"></div>
<div class="circle-90"></div>
</div>
<!-- 270度做法2:180+180(不旋转) -->
<div class="square-box-3">
<div class="circle-180-clip-top"></div>
<div class="circle-180-clip-right"></div>
</div>
<!-- 270度做法3:180+180(旋转90度) -->
<div class="square-box-4">
<div class="circle-180-clip-top"></div>
<div class="circle-180-roate90"></div>
</div>
<!-- 进度圆、进度条 -->
<div class="square-box-5">
<div class="circle-180-clip-top"></div>
<div class="circle-180-roate90"></div>
<div class="circle-90-process"></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {};
}
};
</script>
<style scoped lang="less">
.container-box {
margin-left: 200px;
margin-top: 300px;
.square-box-1 {
position: relative;
width: 800px;
height: 300px;
background: wheat;
.circle-90-left-top {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(auto, 100px, 100px, auto);
border-radius: 50%;
border: 5px solid red;
}
.circle-90-right-top {
position: absolute;
left: 80px;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(auto, auto, 100px, 100px);
border-radius: 50%;
border: 5px solid red;
}
.circle-90-right-bottom {
position: absolute;
left: 80px;
top: 80px;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, 100px);
border-radius: 50%;
border: 5px solid red;
}
.circle-90-bottom-left {
position: absolute;
left: 0;
top: 80px;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, 100px, auto, auto);
border-radius: 50%;
border: 5px solid red;
}
.circle-180 {
position: absolute;
background: green;
left: 300px;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
border-radius: 50%;
border: 5px solid red;
}
.circle-180-roate {
position: absolute;
background: green;
left: 500px;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
transform: rotate(-45deg);
border-radius: 50%;
border: 5px solid red;
}
}
.square-box-2 {
position: relative;
width: 600px;
height: 300px;
margin-top: 100px;
background:wheat;
.circle-180 {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
border-radius: 50%;
border: 5px solid red;
}
.circle-90 {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(auto, 100px, 100px, auto);
border-radius: 50%;
border: 5px solid red;
}
}
.square-box-3 {
position: relative;
width: 600px;
height: 300px;
margin-top: 100px;
background:wheat;
.circle-180-clip-top {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
border-radius: 50%;
border: 5px solid red;
}
.circle-180-clip-right {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(auto, 100px, auto, auto);
border-radius: 50%;
border: 5px solid red;
}
}
.square-box-4 {
position: relative;
width: 600px;
height: 300px;
margin-top: 100px;
background:wheat;
.circle-180-clip-top {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px,auto, auto, 100px);
border-radius: 50%;
border: 5px solid red;
}
.circle-180-roate90 {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
transform: rotate(90deg);
border-radius: 50%;
border: 5px solid red;
}
}
.square-box-5 {
position: relative;
width: 600px;
height: 300px;
margin-top: 100px;
background:wheat;
.circle-180-clip-top {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px,auto, auto, 100px);
border-radius: 50%;
border: 5px solid red;
}
.circle-180-roate90 {
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(100px, auto, auto, auto);
transform: rotate(90deg);
border-radius: 50%;
border: 5px solid red;
}
.circle-90-process{
position: absolute;
background: green;
width: 200px;
height: 200px;
// 上右下左
clip: rect(auto, auto, 100px, 100px);
border-radius: 50%;
border: 5px solid yellow;
}
}
}
</style>
网友评论