【CSS】用CSS绘制图标(图标大全)

14 篇文章 0 订阅

转载请务必注明出处,也不枉我这么辛苦打上来。谢谢啦!
技艺不精,若有纰漏,还请不吝指出。

  • 暂停按钮
    这里写图片描述
    <style>
        .box{
            width: 50px;
            height: 50px;
            background-color: white;
            border: 1px solid black;
            border-radius: 100%;
            outline: 10px solid black;
            outline-offset: -27px;
            cursor: pointer;
        }
    </style>
<body>
    <div class="box"></div>
</body>
  • 加号按钮
    这里写图片描述
            .box{
                width: 50px;
                height: 50px;
                background-color: white;
                border: 1px solid black;
                border-radius: 100%;
                outline: 10px solid black;
                outline-offset: -35px;
                cursor: pointer;
            }
        </style>
    <body>
    <div class="box"></div>

    </body>
  • 关闭按钮
    这里写图片描述
        <style>
            .box{
                width: 50px;
                height: 50px;
                background-color: black;
                border: 1px solid white;
                border-radius: 100%;
                outline: 15px solid white;
                outline-offset: -39px;
                cursor: pointer;
                transform: rotate(45deg);
            }
        </style>
    <body>
    <div class="box"></div>

    </body>
  • 菜单按钮
    这里写图片描述

用阴影实现

        <style>
            .box{
                width: 30px;
                height: 0;
                color: black;
                box-shadow: 20px 10px 0 3px ,20px 0 0 3px ,20px 20px 0 3px;
            }
        </style>
    <body>
    <div class="box"></div>

    </body>

用背景裁剪实现

        <style>
            .box{
                width: 30px;
                height: 5px;
                padding: 5px 0;
                border-top: 5px solid black;
                border-bottom: 5px solid black;
                background-clip: content-box;
                background-color: black;
            }
        </style>
    <body>
    <div class="box"></div>

    </body>

用渐变函数

            <style>
                .box{
                    width: 30px;
                    height: 15px;
                    background: linear-gradient(to bottom,black 0%,black 0%,transparent 20%,transparent 40%, black 40%,black 40%,transparent 60%,transparent 80%,black 100%);
                }
            </style>
        <body>
        <div class="box"></div>

        </body>
  • 文章图标
    这里写图片描述
            <style>
                .box{
                    width: 30px;
                    height: 15px;
                    background: linear-gradient(to bottom,black 0%,black 0%,transparent 20%,transparent 40%, black 40%,black 40%,transparent 60%,transparent 80%,black 100%);
                    outline: 1px solid black;
                    outline-offset: 4px;
                }
            </style>
        <body>
        <div class="box"></div>

        </body>
  • 单选按钮

这里写图片描述

            <style>

                .box{
                    width: 16px;
                    height: 16px;
                    background-color: black;
                    border-radius: 100%;
                    box-shadow: 0 0 0 5px #fff,0 0 0 10px #000;
                }
            </style>

        <body>
        <div class="box"></div>

        </body>
            <style>
                .box{
                    width: 16px;
                    height: 16px;
                    padding: 7px;
                    border: 3px solid green;
                    border-radius: 100%;
                    background-clip: content-box;
                    background-color: green;
                }
            </style>

        <body>
        <div class="box"></div>

        </body>
  • 靶子图标

这里写图片描述

            <style>
                .box{
                    width: 16px;
                    height: 16px;
                    background-color: black;
                    border-radius: 100%;
                    box-shadow: 0 0 0 3px #fff,0 0 0 5px #000;
                    outline: 18px solid #ffffff;
                    outline-offset: -25px;
                    transform: scale(1.5);
                }
            </style>
        <body>
        <div class="box"></div>

        </body>
  • 田字图标
    这里写图片描述
.box{
                    width:0;
                    color: #000;
                    border: 3px solid black;
                    outline: 6px dotted ;
                    outline-offset: 6px;

                }
.box{
                    width:0;
                    padding: 3px;
                    background-color: black;
                    outline: 6px dotted black;
                    outline-offset: 6px;
                }
.box{
                    height: 6px;
                    width: 6px;
                    background-color: black;
                    outline: 6px dotted black;
                    outline-offset: 6px;
                }
  • 下载箭头

这里写图片描述

.box{
                    width: 0;
                    color: #000;
                    border: 8px solid transparent;
                    border-top: 8px solid;
                    box-shadow: 0 -12px 0 -4px;
                }
  • 下载箭头(带横线)

这里写图片描述

.box{
                    width: 1px;
                    height: 6px;
                    color: #000;
                    border: 8px solid transparent;
                    border-top: 8px solid;
                    box-shadow: 0 -12px 0 -4px;
                    background: linear-gradient(to bottom,#ffffff 50%,#000000 50%) repeat-x;
                }
  • 禁用图标
    这里写图片描述
.box{
                    width: 20px;
                    height: 20px;
                    border-radius: 100%;
                    border: 2px solid #000000;
                    background: linear-gradient(to right,#ffffff 45%,#000000 45%,#000 55%,#fff 55%);
                    transform:rotate(40deg);
                }

还有很多的图标等待大家去开发,我这列举几个常用的而已,抛砖引玉。有什么好的图标,还希望大家在博文下回复讨论。
谢谢。
挚谢阅读。

  • 23
    点赞
  • 85
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很好,让我来为您解答。 首先,我们需要使用HTML创建信用卡的基本结构。以下是一个示例代码: ```html <div class="credit-card"> <div class="credit-card__logo"></div> <div class="credit-card__number">1234 5678 9012 3456</div> <div class="credit-card__name">FULL NAME</div> <div class="credit-card__expiration"> <div class="credit-card__expiration-label">Expiration Date</div> <div class="credit-card__expiration-date">MM/YY</div> </div> </div> ``` 接下来,我们需要使用CSS来设计这个信用卡。以下是一个示例代码: ```css .credit-card { width: 400px; height: 250px; background-color: #fafafa; box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.1); border-radius: 10px; display: flex; flex-direction: column; justify-content: space-between; padding: 30px; box-sizing: border-box; position: relative; } .credit-card__logo { width: 80px; height: 50px; background-image: url('credit-card-logo.png'); background-size: contain; background-repeat: no-repeat; background-position: center; position: absolute; top: 20px; right: 20px; } .credit-card__number { font-size: 24px; font-weight: bold; letter-spacing: 4px; } .credit-card__name { font-size: 18px; font-weight: bold; text-transform: uppercase; } .credit-card__expiration { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; } .credit-card__expiration-label { font-size: 12px; font-weight: bold; color: #a9a9a9; } .credit-card__expiration-date { font-size: 18px; font-weight: bold; letter-spacing: 2px; } ``` 上面的CSS样式将为我们的信用卡添加样式,包括背景颜色,阴影,边框半径,文本样式和位置。 最后,我们只需要将HTML和CSS结合起来,就可以创建一个漂亮的信用卡了。如果您有自己的信用卡图标和样式,只需要将其替换为示例代码中的图标和样式即可。 希望这可以帮助您创建一个漂亮的信用卡!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值