Jquery中文网 www.jquerycn.cn
Jquery中文网 >  CSS教程  >  经典实例  >  正文 利用纯CSS制作冒泡提示框效果

利用纯CSS制作冒泡提示框效果

发布时间:2020-05-10   编辑:www.jquerycn.cn
jquery中文网为您提供利用纯CSS制作冒泡提示框效果等资源,欢迎您收藏本站,我们将为您提供最新的利用纯CSS制作冒泡提示框效果资源
以前在分享过一篇关于此类的文章,今天分享一篇文章给大家,如果利用CSS制作冒泡提示框,有需要了 解的朋友可进入参考。

先看2张效果图:

maopao1maopao2

CSS:

 代码如下 复制代码

/*
   对话气泡
   用法:使用.speech-bubble和.speech-bubble-DIRECTION类
   <div class="speech-bubble speech-bubble-top">Hi there</div>
*/
 
.speech-bubble {
  position: relative;
  background-color: #292929;
 
  width: 200px;
  height: 150px;
  line-height: 150px; /* 垂直居中 */
  color: white;
  text-align: center;
  border-radius: 10px;
  font-family: sans-serif;
}
 
.speech-bubble:after {
  content: '';
  position: absolute;
 
  width: 0;
  height: 0;
 
  border: 15px solid;
}
 
/* 箭头的位置 */
.speech-bubble-top:after {
  border-bottom-color: #292929;
  left: 50%;
  bottom: 100%;
  margin-left: -15px; 
}
.speech-bubble-right:after {
  border-left-color: #292929;
 
  left: 100%;
  top: 50%;
  margin-top: -15px;  
}
 
.speech-bubble-bottom:after {
  border-top-color: #292929;
  top: 100%;
  left: 50%;
  margin-left: -15px; 
}
 
.speech-bubble-left:after {
  border-right-color: #292929;
  top: 50%;
  right: 100%;
  margin-top: -15px;  
}
 

HTML:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="maopao.css">
        <title>Test</title>
    </head>
    <body>
        <div class="speech-bubble speech-bubble-top">
            箭头在顶部
        </div>
         <br/>
        <div class="speech-bubble speech-bubble-bottom">
            箭头在底部
        </div>
        <br/>
        <div class="speech-bubble speech-bubble-left">
            箭头在左侧
        </div>
         <br/>
        <div class="speech-bubble speech-bubble-right">
            箭头在右侧
        </div>
    </body>
</html>

 
这个只用到了css没用到有图片哦。

您可能感兴趣的文章:
利用纯CSS制作冒泡提示框效果
Coda Popup Bubbles
由点击页面其它地方隐藏div所想到的jQuery的delegate
jQuery阻止冒泡和HTML默认操作
解密jQuery事件核心 – 模拟事件(四)
基于jquery的气泡提示效果
jquery 事件冒泡的介绍以及如何阻止事件冒泡
php 实现冒泡排序的简单例子
JQuery实现简单时尚快捷的气泡提示插件
JavaScript MVC 学习笔记(五)事件的基本操作

[关闭]