设为首页收藏本站

IITT网络服务中心

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3378|回复: 0
打印 上一主题 下一主题

纯css制作三角箭头提示框

[复制链接]

453

主题

399

帖子

1764

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1764
跳转到指定楼层
楼主
发表于 2016-4-14 21:35:52 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
样式:

html代码
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <link rel="stylesheet" type="text/css" href="maopao.css">
  5.         <title>Test</title>
  6.     </head>
  7.     <body>
  8.         <div class="speech-bubble speech-bubble-top">
  9.             箭头在顶部
  10.         </div>
  11.          <br/>
  12.         <div class="speech-bubble speech-bubble-bottom">
  13.             箭头在底部
  14.         </div>
  15.         <br/>
  16.         <div class="speech-bubble speech-bubble-left">
  17.             箭头在左侧
  18.         </div>
  19.          <br/>
  20.         <div class="speech-bubble speech-bubble-right">
  21.             箭头在右侧
  22.         </div>
  23.     </body>
  24. </html>
复制代码
css代码
  1. <style type="text/css">
  2. /*
  3.    对话气泡
  4.    用法:使用.speech-bubble和.speech-bubble-DIRECTION类
  5.    <div class="speech-bubble speech-bubble-top">Hi there</div>
  6. */

  7. .speech-bubble {
  8.   position: relative;
  9.   background-color: #292929;

  10.   width: 200px;
  11.   height: 150px;
  12.   line-height: 150px; /* 垂直居中 */
  13.   color: white;
  14.   text-align: center;
  15.   border-radius: 10px;
  16.   font-family: sans-serif;
  17. }

  18. .speech-bubble:after {
  19.   content: '';
  20.   position: absolute;

  21.   width: 0;
  22.   height: 0;

  23.   border: 15px solid;
  24. }

  25. /* 箭头的位置 */
  26. .speech-bubble-top:after {
  27.   border-bottom-color: #292929;
  28.   left: 50%;
  29.   bottom: 100%;
  30.   margin-left: -15px;  
  31. }
  32. .speech-bubble-right:after {
  33.   border-left-color: #292929;

  34.   left: 100%;
  35.   top: 50%;
  36.   margin-top: -15px;   
  37. }

  38. .speech-bubble-bottom:after {
  39.   border-top-color: #292929;
  40.   top: 100%;
  41.   left: 50%;
  42.   margin-left: -15px;  
  43. }

  44. .speech-bubble-left:after {
  45.   border-right-color: #292929;
  46.   top: 50%;
  47.   right: 100%;
  48.   margin-top: -15px;   
  49. }

  50. </style>
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|IITT网络服务中心    

GMT+8, 2024-4-27 04:27 , Processed in 0.072996 second(s), 31 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表