使用background多背景与border-radius圆形 - 绘制icon的图标与特别样式的应用

使用css的属性制作一些小众的样式,减少使用对icon图片导入;

使用background多背景实现icon的加减效果

这里应用多背景的属性,书写加减后的图标;代码示例如下:

<style>
.btn-add,
.btn-sub {
    width: 1.5rem; height: 1.5rem;
    border: 1px solid gray;
    background: linear-gradient(currentColor, currentColor) no-repeat center/.875em 2px, 
                linear-gradient(currentColor, currentColor) no-repeat center/2px .875em,
                ghostwhite;
    color: dimgray;
    text-indent: -999px;
}
.btn-sub {
    background-size: .875em 2px, 0;
}
</style>
<button class="btn-add"></button>
<button class="btn-sub"></button>

实现的效果如下图所示:
在这里插入图片描述

border-radius圆形绘制技巧

  1. 实现1/4角标效果示意:
    在这里插入图片描述

关键的css代码如下:

border-bottom-right-radius: 100%;
  1. 带尖角对话框小尾巴效果示意
    在这里插入图片描述
    关键的css代码如下:
width: 15px; height: 10px;
border-top: 10px solid;
border-top-left-radius: 80%;

这里是引用《css新世界》一书中的案例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值