用css画个苦无

作者: 两年半练习程序员 | 来源:发表于2018-10-19 17:12 被阅读0次

效果图


苦无

首先将布局进行拆分


拆分图
3.png

由四部分组成
苦无头(上)
苦无头(下)
苦无握把
苦无指环

苦无头(上):一个尖头朝上的三角形
苦无下(上):一个尖头朝下的三角形
苦无握把:多个圆角矩形
苦无指环:一个带有渐变色的圆环

    <body>
        <div class="box">
            <!-- 头(上) -->
            <div class="top"></div>
            <!-- 头(下) -->
            <div class="center"></div>
            <!-- 握把 -->
            <div class="bottom">
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </div>
            <!-- 指环 -->
            <div class="round"></div>
        </div>
    </body>

三角形怎么画?
将元素宽度设置为0,用border撑起宽高,我们来看下效果`


3 (2).png

如上图所示,我们想得到一个三角形只需要将:三边border的颜色设置为transparent

       .top {
            width: 0;
            margin: 0 auto;
            border-top: 0px solid transparent;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-bottom: 200px solid transparent;
        }

三角形没问题了我们就可以完成苦无头
苦无指环是一个环形渐变

<div class="round">
    <div class="centerRound"></div>
</div>

round为圆型容器,centerRound为圆环空白区,放置在round中间就形成了一个圆环,再给round加一个渐变的伪类after
苦无指环就完成了

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="author" content="Cc">
        <title>苦无</title>
    </head>
    <style>
        * {margin: 0;padding: 0;}
        html,body {display: flex;width: 100%;height: 100%;background: #f7f7f7;align-items: center;}

        .box {position: relative;width: 200px;margin: 0 auto;transition: all .6s;}
        .box:hover{transform: rotate(360deg);}

        .top {
            width: 0;
            margin: 0 auto;
            border-top: 0px solid transparent;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-bottom: 200px solid #6b6b6b;
        }
        .top_shadow{
            position: absolute;
            left: 50%;
            margin-left: -1px;
            top: 15px;
            width: 2px;
            height: 150px;
            background: #fff;
            border-radius:50%;
            box-shadow: 0 0 10px #fff;
        }

        .center {
            position: relative;
            width: 0px;
            margin: 0 auto;
            border-top: 60px solid #6b6b6b;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            border-bottom: 0px solid transparent;
            
        }
        .center1{
            position: absolute;
            top: -80px;
            left: 0px;
            width: 50px;
            height: 2px;
            background: #fff;
            border-radius:50%;
            box-shadow: 0 0 10px #fff;
            transform: rotate(35deg);
        }
        .center2{
            position: absolute;
            top: -80px;
            right: 0px;
            width: 50px;
            height: 2px;
            background: #fff;
            border-radius:50%;
            box-shadow: 0 0 10px #fff;
            transform: rotate(-35deg);
        }

        .bottom {
            z-index: 2;
            top: -15px;
            position: relative;
            width: 50px;
            margin: 0 auto;
        }
        .bottom div{
            width: 30px;
            height: 8px;
            margin: 0 auto;
            border-radius: 5px;
            background: red;
            border-bottom: 0.5px solid #fff;
        }
        .round{
            position: relative;
            margin: 0 auto;
            top: -20px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            
        }
        .centerRound{
            position: absolute;
            width: 30px;
            height: 30px;
            top: 50%;
            left: 50%;
            margin-top: -15px;
            margin-left: -15px;
            background: #fff;
            border-radius: 50%;
            z-index: 1;
        }
        .round:after{
            position: absolute;
            width: 50px;
            height: 50px;
            background: linear-gradient(to right,red, blue);
            content: '';
            border-radius: 50%;
            background: linear-gradient(to bottom right, #000 , #eee);
        }
    </style>
    <body>
        <div class="box">
            <div class="top">
                <div class="top_shadow"></div>
            </div>
            <div class="center">
                <div class="center1"></div>
                <div class="center2"></div>
            </div>
            <div class="bottom">
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </div>
            <div class="round">
                <div class="centerRound"></div>
            </div>
        </div>
    </body>
</html>

相关文章

  • 用css画个苦无

    效果图 首先将布局进行拆分 由四部分组成苦无头(上)苦无头(下)苦无握把苦无指环 苦无头(上):一个尖头朝上的三角...

  • 用css样式画个圈

    用span标签写,要改变他的行内元素的特点。用display:inline-block;改变成为行内块级元素

  • 用 CSS 画胡子

    今天的代码以Css3 为基础来演示。闲话少说,直接画。 先创建一个 index.html 文件,引用 style....

  • 【转】用CSS画各种形状(一)

    本篇是以下两篇文章的转载和总结 纯CSS画基本形状用CSS画三角形,普通版,文艺小阴影版~ 1、画方形 2、画正圆...

  • 《用字体在网页中画ICON图标》笔记

    慕课网 用字体在网页中画ICON图标 学习笔记 一、用 CSS Sprite 实现 icon 图标 CSS Spr...

  • 用 CSS 做像素画

    小时候的游戏机上的游戏人物都是用像素画,那时候就对像素情有独钟。前两年上映的像素大战也勾起许多儿时的回忆。 绘制像...

  • CSS画三角形/梯形

    用css画三角形或者梯形等图片主要是利用css中的border属性 正方形 ==>为一个div设置如下样式.tri...

  • 各种纯css图标

    各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...

  • css 实现三角形箭头

    插入DOM 使用伪类 参考:用纯CSS实现的箭头CSS画三角形原理css整理 -- 右箭头,上下箭头,三角形 这个...

  • css画三角形

    我之前还是真没有用过 css画三角形,用的切图。但是切图要请求网络上的资源。可能不划算所以就要实现 css画各种三...

网友评论

    本文标题:用css画个苦无

    本文链接:https://www.haomeiwen.com/subject/vdcuzftx.html