css画一个推荐图标

这篇博客展示了如何利用CSS创建一个带有三角形箭头的标签。通过设置不同的边框宽度和颜色,实现了三角形效果,并将其与文本内容结合,创建了一个常见的页面元素。这种方法简单且易于理解,适用于前端开发中的各种布局需求。
摘要由CSDN通过智能技术生成

有很多网站上都有出现这样的图标,今天用css就画一个叭
在这里插入图片描述




-----------------------------css部分--------------------------------
<style>
 .common-label{
    position: absolute;
    width: 30px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    color: #fff;
    background-color: #db4659;
    top: 5px;
    left: 10px;
    z-index: 145;
}

 .common-label .triangle {
    position: absolute;
    top: 24px;
    left: -10px;
    width: 0;
    height: 0;
    z-index: 33;
    border-left: 10px solid transparent;
    border-right: 10px solid #df0d3a;
    border-bottom: 7px solid transparent;
    line-height: 24px;
    text-align: center;
    color: #fff;
}
</style>

---------------------------html部分---------------------------------
 <div style="width: 400px;height: 400px;;margin:100px auto;background-color: pink;">
         <p class="common-label">
            <span class="triangle"></span>
        </p>
    </div>


在这里插入图片描述
就ok啦,是不是很简单呢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值