带尖角的div

原以为尖角三角形是png图片,原来是可以用css画出来,css3也可以很简单的得到带圆角的div,

大概思路: 

1.画出一个带细边框的div

2.使用::before和left:100%在div的右边添加一个height和width为0但是带边框的元素

3.使用::after覆盖before

 #demo {
            width: 100px;
            height: 100px;
            background-color: #fff;
            border: 2px rgb(31, 197, 86) solid;
            border-radius:10px;
            position: relative;
        }
      
        /*先画出一个三角形*/
        #demo::before{
            content: '';
            width: 0px;
            height: 0px;
            border:20px solid transparent;/*border设置成透明,但是右边border设置成红色*/
            border-left-color: rgb(55, 82, 235) ;
            top: 10px;
            left: 100%;
            position: absolute;
        }

        /*用透明三角形去覆盖这个三角形*/
        #demo::after{
            content: '';
            width: 0px;
            height: 0px;
            border:18px solid transparent;
            border-left-color: white ;
            top: 12px;
            left: 100%;
            position: absolute;
        }

  这样就出现了一个类似消息发送的形状,css是不是很神奇呢

转载于:https://www.cnblogs.com/MarkSun3/p/9128069.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值