CSS3实现左上角或右上角显示提醒圆点的示例代码

CSS3实现左上角或右上角显示提醒圆点的示例代码,第1张

CSS3实现左上角或右上角显示提醒圆点的示例代码

效果图(如果想要三角形请点击这里): 

代码: 

<html>
<head>
    <style type="text/css">
        .message_s {
            position: relative;
            cursor: pointer;
        }
 
            .message_s:after {
                position: absolute;
                content: "";
                /*以下内容可以根据实际需要进行调整 -----start------*/
                top: 0px;
                left: -13px; /*改成:right: -13px; 圆点显示在右侧*/
                width: 8px;
                height: 8px;
                border-radius: 50%;
                background-color: #e98b7f;
                /*-----end------*/
            }
 
        div {
            height: 30px;
            border: 1px #000 solid;
            width: 300px;
            line-height: 30px;
            padding: 0px 0px 0px 15px;
        }
    </style>
    <script>
        function clickAction()
        {
            console.log("天不生我leader,键道万古长如夜!");
        }
    </script>
</head>
<body>
    <div>
        <span class="message_s" onclick="clickAction()"></span>
        剑开天门
    </div>
</body>
</html>

附录:下面看下左上角实现红色三角号标识

左上角实现红色三角号标识,如图

 利用伪类实现,position和transform、border属性为重点。


位置调整修改top和left的值即可。


<html>
<head>
<title> New Document </title>
<style>
    div {
        background-color: #f4f4f4;
        padding: 20px;
    }
 
    .message_s {
        position: relative;
    }
 
        .message_s:after {
            position: absolute;
            top: -25px;
            display: block;
            width: 0;
            height: 0;
            border: 16px solid transparent;
            content: "";
            -webkit-transform: rotate(45deg);
        }
 
        .message_s:after {
            left: -25px;
            z-index: 0;
            border-right-color: red;
        }
</style>
</head>
<body>
<div>
    <span class="message_s">Internet Explorer 10、Firefox、Opera 支持 transform 属性。


Internet Explorer 9 支持替代的 -ms-transform 属性(仅适用于 2D 转换)。


Safari 和 Chrome 支持替代的 -webkit-transform 属性(3D 和 2D 转换)。


Opera 只支持 2D 转换。


</span> </div> </body> </html>

到此这篇关于CSS3实现左上角或右上角显示提醒圆点的示例代码的文章就介绍到这了,更多相关css3提醒圆点内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/615949.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-14
下一篇2022-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存