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 <style type="text/css">
 7 body{ background:#000; font-family:"微软雅黑"; color:#fff; font-weight:normal;}
 8 .top{
 9     width:0;
10     border-bottom:30px solid #abcdef;
11     border-left:30px solid transparent;
12     border-right:30px solid transparent;
13     }
14 .bottom{
15     width:0;
16     border-top:30px solid #abcdef;
17     border-left:30px solid transparent;
18     border-right:30px solid transparent;
19     }
20 .left{
21     width:0;
22     border-right:30px solid #abcdef;
23     border-top:30px solid transparent;
24     border-bottom:30px solid transparent;
25     }
26 .right{
27     width:0;
28     border-left:30px solid #abcdef;
29     border-top:30px solid transparent;
30     border-bottom:30px solid transparent;
31     }
32
33 </style>
34 </head>
35
36 <body>
37 <h3>朝上三角形:</h3>
38 <div class="top"></div>
39 <h3>朝下三角形:</h3>
40 <div class="bottom"></div>
41 <h3>朝左三角形:</h3>
42 <div class="left"></div>
43 <h3>朝右三角形:</h3>
44 <div class="right"></div>
45
46 </body>
47 </html>

2、容器的实现

1 <div class="content"></div>

容器的css样式:

1 .content{
2     position:relative;
3     width:300px;
4     height:80px;
5     line-height:60px;
6     background:#D6E29A;
7     border-radius:4px;
8     border:1px solid #AEBD30;
9     }

3、箭头+容器=气泡

在容器内绘制一个三角形

<div class="content">
    <div class="cac_top"></div>
</div>

容器内三角形.cac_top的样式为:

 1 .cac_top{
 2     width:0;
 3     border-top:20px solid #D6E29A;
 4     border-left:20px solid transparent;
 5     border-right:20px solid transparent;
 6     position:absolute;
 7     bottom:-20px;
 8     left:100px;
 9
10     }

此时气泡的样子为:

不难发现小三角并没有被边框,我们需要在div内再添加一个小三角,将其背景色设置成容器边框的颜色,充当三角的边框,具体代码如下:

1 <div class="content">
2     <div class="cac_bg"></div><!-- 背景三角 -->
3     <div class="cac_bder"></div><!-- 边框三角 -->
4 </div>

css为:

 1 .cac_bder{
 2     width:0;
 3     border-top:20px solid #AEBD30;
 4     border-left:20px solid transparent;
 5     border-right:20px solid transparent;
 6     position:absolute;
 7     bottom:-20px;
 8     left:100px;
 9     z-index:1;
10
11     }
12 .cac_bg{
13     width:0;
14     border-top:19px solid #D6E29A;
15     border-left:19px solid transparent;
16     border-right:19px solid transparent;
17     position:absolute;
18     bottom:-19px;
19     left:101px;
20     z-index:2;
21
22     }

此时气泡的样子为:

完整代码如下:

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5 <title>上下左右三角形</title>
 6 <style type="text/css">
 7 body{ background:#fff; font-family:"微软雅黑"; color:#333; font-weight:normal;}
 8 .top{
 9     width:0;
10     border-bottom:30px solid #abcdef;
11     border-left:30px solid transparent;
12     border-right:30px solid transparent;
13     }
14 .bottom{
15     width:0;
16     border-top:30px solid #abcdef;
17     border-left:30px solid transparent;
18     border-right:30px solid transparent;
19     }
20 .left{
21     width:0;
22     border-right:30px solid #abcdef;
23     border-top:30px solid transparent;
24     border-bottom:30px solid transparent;
25     }
26 .right{
27     width:0;
28     border-left:30px solid #abcdef;
29     border-top:30px solid transparent;
30     border-bottom:30px solid transparent;
31     }
32 .content{
33     position:relative;
34     width:300px;
35     height:80px;
36     line-height:60px;
37     background:#D6E29A;
38     border-radius:4px;
39     border:1px solid #AEBD30;
40     }
41 .cac_bder{
42     width:0;
43     border-top:20px solid #AEBD30;
44     border-left:20px solid transparent;
45     border-right:20px solid transparent;
46     position:absolute;
47     bottom:-20px;
48     left:100px;
49     z-index:1;
50
51     }
52 .cac_bg{
53     width:0;
54     border-top:19px solid #D6E29A;
55     border-left:19px solid transparent;
56     border-right:19px solid transparent;
57     position:absolute;
58     bottom:-19px;
59     left:101px;
60     z-index:2;
61
62     }
63
64 </style>
65 </head>
66
67 <body>
68 <h3>朝上三角形:</h3>
69 <div class="top"></div>
70 <h3>朝下三角形:</h3>
71 <div class="bottom"></div>
72 <h3>朝左三角形:</h3>
73 <div class="left"></div>
74 <h3>朝右三角形:</h3>
75 <div class="right"></div>
76 <h3>div容器</h3>
77 <div class="content">
78     <div class="cac_bg"></div><!-- 背景三角 -->
79     <div class="cac_bder"></div><!-- 边框三角 -->
80 </div>
81 </body>
82 </html>
时间: 2024-07-28 23:04:10

css 气泡提示框的相关文章

可自定义配置箭头的CSS3气泡提示框

今天我们要来分享一款基于纯CSS的气泡提示框,和之前分享的一款jQuery消息提示框插件Tipso类似,整个提示框由箭头和矩形框组成,并且气泡提示框的箭头可以有不同的方向.这款CSS气泡提示框由纯CSS完成,最大的特点就是可以自定义配置,包括文字颜色.背景颜色和箭头方向等.效果图如下: 在线预览   源码下载 实现的代码. css代码: .arrow_box { position: relative; background: #88b7d5; border: 4px solid #c2e1f5;

纯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"> <html> <head> <meta charset=&quo

Arc Engine 中添加气泡提示框

一.在ArcMap中的定位操作 已知若干点的经纬度坐标,要求在地图中进行定位: 1.通过Tool >Add X Y data 定位点,注意选择地理坐标系下的wgs 1984坐标系: 2.定位后的点不能执行查询.分析等操作,需要重新export data: 3.导出的数据最好转换成投影坐标,以便于计算.可首先把已知投影坐标的图层加载到地图中,然后加入第二步产生的点图层,然后将点图层export data,注意坐标系统选择“the data frame” 二.在ArcObject开发时定位的代码示例

支持鼠标跟随的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

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实现提示框小三角

<!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

气泡提示框

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus

WPF 气泡提示框的简单实现

自己挖了一个大坑,,,然后苦逼的在码代码重写样式! 废物不多少 直接上代码 1 <TextBox Name="account" GotFocus="account_GotFocus" LostFocus="account_LostFocus" Style="{StaticResource LabelTextBox}" xl:ControlAttachProperty.Label="用户名:" Fore

纯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; ov