找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1861|回复: 0

[教程] CSS3 tooltips 信息提示框

[复制链接]
发表于 2012-4-13 11:43:14 | 显示全部楼层 |阅读模式 来自 中国–江苏–南京
本帖最后由 mseed 于 2012-4-13 11:45 编辑

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>demo - daqianduan.com</title>
  6. <style>

  7. body{
  8. font:normal 12px/18px simsun;
  9. }
  10. .tooltip
  11. {
  12. position: relative;
  13. background: #eaeaea;
  14. cursor: help;
  15. display: inline-block;
  16. text-decoration: none;
  17. color: #222;
  18. outline: none;
  19. }

  20. .tooltip span
  21. {
  22. visibility: hidden;
  23. position: absolute;
  24. bottom: 30px;
  25. left: 50%;
  26. z-index: 999;
  27. width: 230px;
  28. margin-left: -127px;
  29. padding: 10px;
  30. border: 2px solid #ccc;
  31. opacity: .9;
  32. background-color: #ddd;
  33. background-image: -webkit-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  34. background-image: -moz-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  35. background-image: -ms-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  36. background-image: -o-linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  37. background-image: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,0));
  38. -moz-border-radius: 4px;
  39. border-radius: 4px;
  40. -moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
  41. -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
  42. box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
  43. text-shadow: 0 1px 0 rgba(255,255,255,.4);
  44. }

  45. .tooltip:hover
  46. {
  47. border: 0; /* IE6 fix */
  48. }

  49. .tooltip:hover span
  50. {
  51. visibility: visible;
  52. }

  53. .tooltip span:before,
  54. .tooltip span:after
  55. {
  56. content: "";
  57. position: absolute;
  58. z-index: 1000;
  59. bottom: -7px;
  60. left: 50%;
  61. margin-left: -8px;
  62. border-top: 8px solid #ddd;
  63. border-left: 8px solid transparent;
  64. border-right: 8px solid transparent;
  65. border-bottom: 0;
  66. }

  67. .tooltip span:before
  68. {
  69. border-top-color: #ccc;
  70. bottom: -8px;
  71. }

  72. /* Yellow */

  73. .yellow-tooltip span
  74. {

  75. border-color: #e1ca82;
  76. background-color: #ffeaa6;
  77. }

  78. .yellow-tooltip span:after
  79. {
  80. border-top-color: #ffeaa6;
  81. }

  82. .yellow-tooltip span:before
  83. {
  84. border-top-color: #e1ca82;
  85. }

  86. /* Navy */

  87. .navy-tooltip span
  88. {
  89. color: #fff;
  90. text-shadow: 0 1px 0 #000;
  91. border-color: #161a1f;
  92. background-color: #1e2227;
  93. }

  94. .navy-tooltip span:after
  95. {
  96. border-top-color: #1e2227;
  97. }

  98. .navy-tooltip span:before
  99. {
  100. border-top-color: #161a1f;
  101. }

  102. /* Blue */

  103. .blue-tooltip span
  104. {
  105. border-color: #59add4;
  106. background-color: #61bde7;
  107. }

  108. .blue-tooltip span:after
  109. {
  110. border-top-color: #61bde7;
  111. }

  112. .blue-tooltip span:before
  113. {
  114. border-top-color: #59add4;
  115. }

  116. /* Pink */

  117. .pink-tooltip span
  118. {
  119. border-color: #ce4378;
  120. background-color: #ea4c88;
  121. }

  122. .pink-tooltip span:after
  123. {
  124. border-top-color: #ea4c88;
  125. }

  126. .pink-tooltip span:before
  127. {
  128. border-top-color: #ce4378;
  129. }
  130. </style>
  131. </head>
  132. <body>

  133. <h3>
  134. Gray tooltip
  135. </h3>
  136. <p>
  137. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tempus nisi
  138. <a class="tooltip" href="#">
  139. vulputate
  140. <span>
  141. <b>
  142. Optional title
  143. </b>
  144. <br>
  145. This is a gray CSS3 tooltip.
  146. </span>
  147. </a>
  148. nulla pretium egestas. Aliquam pretium eros congue
  149. <a class="tooltip" href="#">
  150. ultrices
  151. <span>
  152. This is another gray tooltip made with CSS3 only.
  153. </span>
  154. </a>
  155. mauris auctor lobortis.
  156. </p>

  157. <h3>
  158. Yellow tooltip
  159. </h3>
  160. <p>
  161. Etiam non malesuada nunc. Curabitur bibendum, sapien ornare placerat pellentesque,
  162. <a class="tooltip yellow-tooltip" href="#">
  163. velit
  164. <span>
  165. <b>
  166. Optional title
  167. </b>
  168. <br>
  169. This is a yellow CSS3 tooltip.
  170. </span>
  171. </a>
  172. , nibh
  173. consequat nulla, ac laoreet
  174. <a class="tooltip yellow-tooltip" href="#">
  175. justo
  176. <span>
  177. This is another yellow tooltip made with CSS3 only.
  178. </span>
  179. </a>
  180. lacus lectus ac enim.
  181. </p>

  182. <h3>
  183. Navy tooltip
  184. </h3>
  185. Nulla volutpat mattis egestas. Integer a neque at lorem ornare
  186. <a class="tooltip navy-tooltip" href="#">
  187. accumsan
  188. <span>
  189. <b>
  190. Optional title
  191. </b>
  192. <br>
  193. This is a navy CSS3 tooltip.
  194. </span>
  195. </a>
  196. quis quis ipsum.
  197. Nam id erat mi. Etiam
  198. <a class="tooltip navy-tooltip" href="#">
  199. semper
  200. <span>
  201. This is another navy tooltip made with CSS3 only.
  202. </span>
  203. </a>
  204. velit non risus ultricies faucibus.
  205. <p>
  206. </p>

  207. <h3>
  208. Blue tooltip
  209. </h3>
  210. <p>
  211. Nullam tristique, eros nec feugiat bibendum, orci velit commodo
  212. <a class="tooltip blue-tooltip" href="#">
  213. justo
  214. <span>
  215. <b>
  216. Optional title
  217. </b>
  218. <br>
  219. This is a blue CSS3 tooltip.
  220. </span>
  221. </a>
  222. , non ornare odio massa et ipsum.
  223. Cras scelerisque
  224. <a class="tooltip blue-tooltip" href="#">
  225. ultrices
  226. <span>
  227. This is another blue tooltip made with CSS3 only.
  228. </span>
  229. </a>
  230. leo congue laoreet.
  231. </p>

  232. <h3>
  233. Pink tooltip
  234. </h3>
  235. <p>
  236. Etiam non malesuada nunc. Curabitur bibendum, sapien ornare placerat pellentesque,
  237. <a class="tooltip pink-tooltip" href="#">
  238. velit
  239. <span>
  240. <b>
  241. Optional title
  242. </b>
  243. <br>
  244. This is a pink CSS3 tooltip.
  245. </span>
  246. </a>
  247. , nibh
  248. consequat nulla, ac laoreet
  249. <a class="tooltip pink-tooltip" href="#">
  250. justo
  251. <span>
  252. This is another pink tooltip made with CSS3 only.
  253. </span>
  254. </a>
  255. lacus lectus ac enim.
  256. </p>


  257. <br>
  258. <br>

  259. </body>
  260. </html>
复制代码

CSS3 tooltips 信息提示框纯css3 写的 tooltips 信息提示框,实用性很强,向下兼容页较好

大家看看呢?似乎还行~~~


效果预览地址:http://www.tianyizone.com/css3-tooltips-%e4%bf%a1%e6%81%af%e6%8f%90%e7%a4%ba%e6%a1%86/



评分

参与人数 1金币 +3 收起 理由
光明使者 + 3 赞一个!

查看全部评分

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

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

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2024-11-22 00:17 , Processed in 0.048532 second(s), 13 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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