利用css实现消息提示框效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            padding: 30px;
        }
        /* 消息提示框1-start */
        #comment_bubble {
            width: max-content;
            height: auto;
            background: #088cb7;
            position: relative;
            -moz-border-radius: 12px;
            -webkit-border-radius: 12px;
            border-radius: 12px;
            padding: 15px;
            max-width: 200px;
            color: #fff;
        }
        
        #comment_bubble:before {
            content: "";
            width: 0;
            height: 0;
            right: 100%;
            top: 30%;
            position: absolute;
            border-top: 10px solid transparent;
            border-right: 13px solid #088cb7;
            border-bottom: 10px solid transparent;
        }
        /* 消息提示框1-end */


        /* 消息提示框2-start */
        .tip_box {
            position: relative;
            display: inline-block;
        }
        .tip_box .tip_text {
            position: absolute;
            left: -50%;
            top: calc(100% + 12px);
            width: max-content;
            font-size: 12px;
            font-weight: 400;
            word-break: break-word;
            padding: 6px 8px;
            border-radius: 4px;
            z-index: 99999;
            background: #fff;
            border: 1px solid #303133;
            color: #303133;
        }
        .tip_box .tip_text:before {
            content: "";
            position: absolute;
            top: -7px;
            left: 5px;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 0 8px 8px;
            border-color: transparent transparent #fff;
            z-index: 1;
        }
        .tip_box .tip_text:after {
            content: "";
            position: absolute;
            top: -8px;
            left: 5px;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 0 8px 8px;
            border-color: transparent transparent #303133;
        }
        /* 消息提示框2-end */
    </style>
</head>
<body>
    <div class="container">
        <!-- 消息提示框1 -->
        <h3>第一种消息提示框的效果如下:</h3>
        <div id="comment_bubble">消息提示框内容:消息提示框内容消息提示框内容消息提示框内容消息提示框内容</div>

        <!-- 消息提示框2 -->
        <h3>第二种消息提示框的效果如下:</h3>
        <div class="tip_box">
            <div class="tip_text">消息提示框内容:消息提示框内容</div>
        </div>
    </div>
</body>
</html>

实现效果:
在这里插入图片描述
利用css实现其他形状:
参考链接:https://www.cnblogs.com/liangxiaofeng/p/5936760.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值