html把圆形分成10份,CSS八等分圆的实现示例

简介

对于CSS的练习介绍如何绘制八等分的圆。

问题1 主要思路

这个地方的主要思路是将一个八等分的圆分成两部分。左边和右边的圆分别用半圆旋转而得。

1 注意:每个半圆最后要用外面的外包矩形切一下 详见#lfet #right

2 右边旋转的圆顺序不一样后面的可能会遮挡前面的要么顺序要对,要么使用z-index

问题2 重点代码

1 半圆和圆

.circle-left{

width: 100px;height: 200px;

border-radius: 0px 100px 100px 0px;

position: absolute;

right: 0;

transform-origin: 0 50%;

}

.circle-right{

width: 100px;height: 200px;

border-radius: 100px 0px 0px 100px ;

position: absolute;

right: 0;

transform-origin: 100% 50%;

}

#circle0{

width: 200px;height: 200px;

border-radius: 100px;background-color: yellowgreen;

position: relative;

}

上面采用的是border-radius实现圆和半圆

2 将半圆切整齐

#left{

clip: rect(0px 100px 200px 0px);

position: absolute;

right: 0px;

width: 100px;

height: 200px;

overflow: hidden;

}

使用clip属性将其切整齐

clip只有一种值rect(a,b,c,d)

代码:

CSS等分圆

.circle-left{

width: 100px;height: 200px;

border-radius: 0px 100px 100px 0px;

position: absolute;

right: 0;

transform-origin: 0 50%;

}

.circle-right{

width: 100px;height: 200px;

border-radius: 100px 0px 0px 100px ;

position: absolute;

right: 0;

transform-origin: 100% 50%;

}

#circle0{

width: 200px;height: 200px;

border-radius: 100px;background-color: yellowgreen;

position: relative;

}

#circle2{

background-color: #70f3ff;

}

#circle3{

background-color: #ff461f;

transform: rotate(45deg);

}

#circle4{

background-color: #bce672;

transform: rotate(90deg);

}

#circle5{

background-color: #ffffff;

transform: rotate(135deg);

}

#circle6{

background-color: #3b2e7e;

transform: rotate(180deg);

}

#circle7{

background-color: #ff2121;

transform: rotate(225deg);

}

#circle8{

background-color: #16a951;

transform: rotate(270deg);

}

#circle9{

background-color: #e0eee8;

transform: rotate(315deg);

}

#left{

clip: rect(0px 100px 200px 0px);

position: absolute;

right: 0px;

width: 100px;

height: 200px;

overflow: hidden;

}

#right{

clip: rect(0px 100px 200px 0px);

position: absolute;

left: 0px;

width: 100px;

height: 200px;

overflow: hidden;

}

截图

5fb44be2fc729babda35b99fee207edc.png

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值