纯css三角提示框,兼容IE8

利用border属性实现

 .messageBox{
           position: relative;
           width: 240px;
           height: 60px;
           line-height: 60px;
           background: #e9fbe4;
           border: 1px solid #c9e9c0;
           border-radius: 4px;
           text-align: center;
           color: #0c7823;
       }
        .triangleBorder{
            position: absolute;
            left: 30px;
            overflow: hidden;
            width: 0;
            height: 0;border-width: 10px;border-style: solid dashed dashed dashed;
        }
        .tbBorder{
            bottom: -20px;
            border-color: #c9e9c0 transparent transparent transparent;
        }
        .tbBackground{
            bottom: -19px;border-color: #e9fbe4 transparent transparent transparent;
        }
<div class="messageBox">
    <span>我是利用border属性实现的</span>
    <div class="triangleBorder tbBorder"></div>
    <div class="triangleBorder tbBackground"></div>
</div>

第2种:利用“?”字符实现(谷歌浏览器显示不正常)

 
   IE 火狐  谷歌
.messageBox{
           position: relative;
           width: 240px;
           height: 60px;
           line-height: 60px;
           background: #e9fbe4;
           box-shadow: 1px 2px 3px #e9f4e4;
           border: 1px solid #c9e9c0;
           border-radius: 4px;
           text-align: center;
           color: #0c7823;
       }
        .triangleBorder{
            position: absolute;
            left: 30px;
            overflow: hidden;
            width: 26px;
            height: 26px;
            font: normal 26px "SimSun";
        }
        .tbBorder{
            bottom: -12px;
            color: #c9e9c0;
        }
        .tbBackground{
            bottom: -11px;color: #e9fbe4;
        }
<div class="messageBox">
    <span>我是利用?字符实现的</span>
    <div class="triangleBorder tbBorder">?</div>
    <div class="triangleBorder tbBackground">?</div>
</div>

第3种

.triangle {
            position: relative;
            width: 100px;
            height: 50px;
            border: 2px solid #4ed621;
            border-radius: 5px;
        }

        .triangle:before {
            position: absolute;
            content: "";
            top: -10px;
            left: 25px;
            border-left: 10px solid transparent;
            border-right: 10px solid transparent;
            border-bottom: 10px solid #4ed621;
        }
        /* 白色覆盖*/
        .triangle:after {
            position: absolute;
            content: "";
            /*减少两像素*/
            top: -8px;
            left: 25px;
            border-left: 10px solid transparent;
            border-right: 10px solid transparent;
            border-bottom: 10px solid #fff;
        }
<div class="triangle"></div>

第4种

 .box{
            position: relative;
            padding-top: 8px;
        }
        .con{
            width: 200px;
            height: 100px;
            border: 1px skyblue solid;
            border-radius: 3px;
            background-color: skyblue;
        }
        .con-ret {
            border: 7px solid transparent;
            border-bottom-color: skyblue;
            position: absolute;
            left: 10px;
            top: -6px;

        }
<div class="box">
    <div class="con-ret"></div>
    <div class="con"></div>
</div>

第5种

.main{
            width: 120px;
            padding: 10px;
            font-size: 14px;
            color: #333;
            line-height: 28px;
            background: #F0981C;
            border: 2px solid #FF0000;
            position: relative;
            -webkit-border-radius:5px;
            -moz-border-radius:5px;
            border-radius: 5px;
            display: inline-block;
        }

        .main:before,.main:after{
            content: ‘ ‘;
            border-top: 12px solid #FF0000;
            border-left: 12px solid transparent;
            border-right: 12px solid transparent;
            position: absolute;
            bottom: -12px;
            left: 20px;
        }
        .main:after{
            border-top: 12px solid #F0981C;
            bottom: -9px;
        }
<div class="main">
    <p>这是内容这是内容这是内容</p>
</div>

原文地址:https://www.cnblogs.com/coldfishdt/p/10357649.html

时间: 2024-10-28 19:52:14

纯css三角提示框,兼容IE8的相关文章

纯CSS实现提示框小三角

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

利用CSS中的:after、: before制作的边三角提示框

小颖昨天分享了一篇参考bootstrap中的popover.js的css画消息弹框今天给大家再分享一篇使用:before和:after伪元素画消息弹框的CSS. 画出来是介个酱紫的: 有没有觉得画的萌萌哒,嘻嘻 不贫了,我们一起看代码吧!啦啦啦啦啦啦啦 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style med

支持鼠标跟随的JS+CSS链接提示框

觉得纯css的tips限制有点大,而且好像兼容性也不好,这是我发现的一个Js+CSS的链接提示框效果,还会跟随鼠标而移动,而且兼容性也不错,代码与大家分享:前端分享 .代码   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=&qu

使用checkbox实现纯CSS下拉框

今天给大家讲一个css例子,主要内容是使用checkbox实现纯css下拉框,要用到了HTML元素的checkbox 和CSS3选择器(http://www.maiziedu.com/course/web/228-2627/),并没有用到JavaScript.例子如下: 实现过程: HTML结构 <div class="dropdown"> <input type="checkbox" id="checkbox_toggle"&

css span提示框 练习(不能用div)

<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link href="style/style.css" rel="stylesheet" type="text

纯css实现省略号,兼容火狐,IE9,chrome

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>多行文本实现省略号显示</title> </head> <style type="text/css"> /*纯css实现省略号,兼容火狐,IE9,chrome*/ .wrap{ height:40px;line-h

css 气泡提示框

知识点整理之css气泡框 1.气泡框构成——三角形箭头+容器 其中 三角形的实现:上下左右四个方向的三角形实现方式: 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>上下左右三角形</title> 6 <sty

纯CSS实现气泡框

效果图如下: 源码: <!DOCTYPE html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3c.org/tr/html4/loose.dtd"> <html> <head> <meta charset="utf-8"> <title></title> <style type="

纯CSS“三角边”的实现

<!doctype html> <html> <body> <h2>看看这个例子就会明白所谓“三角边”了|河北冷风机</h2> <div style="border-width:40px;border-style:solid;border-color:red green black blue;line-height:0;font-size:0;width:100px;height:0"></div> &