CSS八等分圆

栏目: CSS · 发布时间: 6年前

内容简介:这个地方的主要思路是将一个八等分的圆分成两部分。左边和右边的圆分别用半圆旋转而得。1 注意:每个半圆最后要用外面的外包矩形切一下 详见#lfet #right 2 右边旋转的圆顺序不一样后面的可能会遮挡前面的要么顺序要对,要么使用z-index上面采用的是border-radius实现圆和半圆

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

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)

代码:

<!DOCTYPE html>
<html>
<head>
    <title>CSS等分圆</title>
    <meta charset="utf-8">
    <style type="text/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;
        }
    </style>
</head>
<body>

    <div id="circle0">
        <div id="left">
            <div class="circle-left" id="circle2"></div>
            <div class="circle-left" id="circle3"></div>
            <div class="circle-left" id="circle4"></div>
            <div class="circle-left" id="circle5"></div>
        </div>
        <div id="right">
            <div class="circle-right" id="circle9"></div>
            <div class="circle-right" id="circle8"></div>
            <div class="circle-right" id="circle7"></div>
            <div class="circle-right" id="circle6"></div>
            
        </div>
    </div>
</body>
</html>
复制代码

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

数据结构与算法经典问题解析

数据结构与算法经典问题解析

纳拉辛哈·卡鲁曼希 / 骆嘉伟 / 机械工业出版社 / 2016-6-1 / CNY 79.00

本书是一本数据结构方面的优秀教材,以Java为描述语言,介绍了计算机编程中使用的数据结构和算法。本书强调问题及其分析,而非理论阐述,共分为21章,讲述了基本概念、递归和回溯、链表、栈、队列、树、优先队列和堆、并查集DAT、图算法、排序、查找、选择算法(中位数)、符号表、散列、字符串算法、算法设计技术、贪婪算法、分治算法、动态规划算法、复杂度类型等内容。每章首先阐述必要的理论基础,然后给出问题集。全......一起来看看 《数据结构与算法经典问题解析》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码