温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

纯CSS怎么制作各种各样的网页图标

发布时间:2021-06-17 13:36:11 阅读:213 作者:小新 栏目:web开发
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章将为大家详细讲解有关纯CSS怎么制作各种各样的网页图标,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

三角形

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
.box{
            width0;
            height0;
            border-top50px solid transparent;
            border-bottom50px solid transparent;
            border-left50px solid transparent;
            border-right50px solid red;
}
</style>

平行四边形图标

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
 .box{
            width50px;
            height50px;
            margin100px auto;
            background-color: red;
            transformskew(-25deg);
        }
</style>

暂停按钮

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
    <style>
        .box{
            width50px;
            height50px;
            margin100px auto;
            color#000;
            border1px solid;
            border-radius50%;
            outline10px solid;
            outline-offset: -26px;
        }
    </style>

暂停按钮的实现原理就是边框用border,里面的正方形用outline。因为outline有一个offset属性可以用来设置偏移量,并且是按照比例来的。

其实如果再将outline-offset的值设置小一点,一个加好就出来了

加号

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box{
        width50px;
        height50px;
        margin100px auto;
        color#000;
        border1px solid;
        border-radius50%;
        outline10px solid;
        outline-offset: -35px;
    }
</style>

如果再将其旋转,就变成了一个关闭按钮

关闭按钮

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box{
        width50px;
        height50px;
        margin100px auto;
        color#000;
        border1px solid;
        border-radius50%;
        outline10px solid;
        outline-offset: -35px;
        transformrotate(45deg);
    }

汉堡按钮

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box{
        width50px;
        height0px;
        margin100px auto;
        box-shadow36px 10px 0 3px red,
        36px 0 0 3px red,
        36px 20px 0 3px red;
    }
</style>

汉堡按钮2:

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box{
        width30px;
        height3px;
        margin100px auto;
        padding2px 0;
        border-top3px solid red;
        border-bottom3px solid red;
        background-clip: content-box;
        background-color: red;
    }
</style>

单选按钮

纯CSS怎么制作各种各样的网页图标

因为box-shadow会按比例缩放,因此将第一个值设置为白色,然后将第二个值设置的比第一个值大就可以了

<div class="box"></div>
<style>
    .box{
        width30px;
        height30px;
        margin100px auto;
        background-color#000;
        border-radius50%;
        box-shadow0 0 0 5px #fff,0 0 0 10px #000;
    }
</style>

圆圈中带个十字

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box {
        width30px;
        height30px;
        margin100px auto;
        background-color#000;
        border-radius50%;
        box-shadow0 0 0 5px #fff0 0 0 10px #000;
        outline36px solid #fff;
        outline-offset: -50px;
    }
</style>

田型图标

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box {
        width0;
        margin100px auto;
        border3px solid red;
        outline6px dotted red;
        outline-offset6px;
    }
</style>

下载箭头

纯CSS怎么制作各种各样的网页图标

使用border制作三角形,使用box-shadow制作正方形,主要用了偏移

<div class="box"></div>
<style>
    .box {
        width0;
        margin100px auto;
        color: red;
        border8px solid transparent;
        border-top8px solid red;
        box-shadow0 -12px 0 -4px;
    }
</style>

书签

纯CSS怎么制作各种各样的网页图标

实现这种效果的原理就是讲三角形设置成背景色,这样空心的三角形就出现了

<div class="box"></div>
<style>
    .box {
        width0;
        height8px;
        background-color:orange;
        border8px solid transparent;
        border-bottom8px solid #fff;
    }
</style>

两个半圆图标

纯CSS怎么制作各种各样的网页图标

这个比较简单,就是通过渐变函数来实现,然后来个圆角边框

<div class="box"></div>
<style>
    .box {
       width50px;
        height50px;
        border-radius50%;
        background-imagelinear-gradient(to right,#ccc 50%,#000 50%);
    }
</style>

禁用图标

纯CSS怎么制作各种各样的网页图标

外圈利用圆角边框,里面的竖线用渐变来做,然后再用旋转属性即可

<div class="box"></div>
<style>
    .box {
       width50px;
        height50px;
        border-radius50%;
        border:2px solid #000;
        backgroundlinear-gradient(to right,#fff  45%,#000 45%,#000 45%,#fff 55%);
        transformrotate(40deg);
    }
</style>

左右箭头图标

纯CSS怎么制作各种各样的网页图标

既然能做出一个三角形,那么就可以做出两个三角形。

<div class="box"></div>
<style>
    .box {
        width0;
        height0;
        margin100px auto;
        border10px solid transparent;
        border-left10px solid red;
        -webkit-box-reflect: left 5px;
        box-reflect:left 5px;
    }
</style>

需要在Chrome浏览器中打开,因为其他浏览器或许不支持

鹰嘴图标

纯CSS怎么制作各种各样的网页图标

<div class="box"></div>
<style>
    .box {
       width32px;
        margin100px auto;
        border-top50px solid transparent;
        border-right22px solid #096;
        border-bottom-right-radius100%;;
    }
</style>

关于“纯CSS怎么制作各种各样的网页图标”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://www.jb51.net/css/605363.html

css
AI

开发者交流群×