打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
纯CSS写成的气泡提示

日期:2012-4-11  来源:GBin1.com

在线演示  在线调试  本地下载

作为前端开发人员,我们都熟悉使用CSS来生成页面上丰富的样式,对于边框border属性来说,也是我们最熟悉不过的CSS属性,今天我们这里将介绍如何使用纯CSS来生成一个气泡式样的提示框,希望大家喜欢!

在这篇文章中我们将使用:after伪标签来生成提示框的指示箭头。

首先我们定义提示框相关属性,我们添加了box阴影和文字阴影效果,这样让提示框更加漂亮:

/* bubble */.tip-bubble {  position: relative;  background-color: #202020;  width: 100px;  padding: 20px;  color: #CCC;  text-align: center;  border-radius: 10px;  margin: 50px;  border: 1px solid #111;  box-shadow: 1px 1px 2px #202020;  -moz-box-shadow: 1px 1px 2px #202020;  -webkit-border-shadow: 1px 1px 2px #202020;  text-shadow: 0px 0px 15px #fff;}

接下来我们处理:after伪标签:

.tip-bubble:after {  content: '';  position: absolute;  width: 0;  height: 0;  border: 15px solid;} 

最后我们定义提示框的箭头方向:

HTML 文件内容:

                <h1>Bubble Tips by CSS</h1>
                
                <div class="tip-bubble tip-bubble-left">GBin1.com Arrow on left </div>

                <div class="tip-bubble tip-bubble-right">GBin1.com Arrow on Right</div>

                <div class="tip-bubble tip-bubble-top">GBin1.com Arrow on top</div>

                <div class="tip-bubble tip-bubble-bottom">GBin1.com  Arrow on bottom</div>?


CSS文件内容:

            /* Layout */
            body{
                font-size:14px;
                font-family:arial;
                background#CCC;
            }
            
            #container{
                marginauto;
                width600px;
                padding-top10px;
            }
            
            h1{
                font-size28px;
                margin50px;
            }
            
            /* bubble */
            .tip-bubble {
              positionrelative;
              background-color#204020;
              width100px;
              padding20px;
              color#CCC;
              text-aligncenter;
              border-radius10px;
              margin50px;
              border1px solid #111;
              border-shadow1px 1px 2px #CCC;
              text-shadow0px 0px 5px #404040;
            }
             
            .tip-bubble:after {
              content'';
              positionabsolute;
              width0;
              height0;
              border15px solid;
            }
             
            /* Position the Arrow */
            .tip-bubble-top:after {
              border-bottom-color#202020;
              left50%;
              bottom100%;
              margin-left-15px;
            }
            .tip-bubble-right:after {
              border-left-color#202020;
              left100%;
              top50%;
              margin-top-15px;
            }
             
            .tip-bubble-bottom:after {
              border-top-color#202020;
              top100%;
              left50%;
              margin-left-15px;
            }
             
            .tip-bubble-left:after {
              border-right-color#202020;
              top50%;
              right100%;
              margin-top-15px;
            }?


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
纯CSS打造Bubble气泡提示框
DIV+CSS圆角边框 - 前端LOVER - 博客园
使用Web标准建站第8天:CSS布局入门
基于DIV+ul+li实现的表格(多示例)
css中元素水平垂直居中4种方法介绍_Div Css教程_三联
对网站速度优化的10个简单步骤
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服