單純使用CSS實現動態提示資訊_CSS/HTML

來源:互聯網
上載者:User
也許已經有人發現可以這樣寫...

CSS代碼部分
a.info {
position:relative; z-index:0; background-color:#ccc; color:#000; text-decoration:none }

a.info:hover {
z-index:1; background-color:#ff0 }

a.info span {
display: none }

a.info:hover span {
display:block; position:absolute; top:12px; left:2px; width:160px; border:1px solid #0cf; background-color:#cff; color:#000; text-align: center }

body區調用方法
1. 需要添加註釋的文本提示資訊

2.提示資訊
<style> body { font:verdena; font-size:14px; color:#000 } h1{ font:verdena; font-size:22px; color:#000 } h2{ font:verdena; font-size:15px; color:#000; text-align:left } div#main { margin:30 } /*關鍵代碼開始*/ a.info { position:relative; z-index:0; background-color:#ccc; color:#000; text-decoration:none } a.info:hover { z-index:1; background-color:#ff0 } a.info span { display: none } a.info:hover span { display:block; position:absolute; top:25px; left:60px; width:130px; border:1px solid #0cf; background-color:#cff; color:#000; text-align: center } /*關鍵代碼結束*/ </style> <body> <h1>單純使用CSS實現動態提示資訊</h1> <h1>不用js可以實現資訊提示效果?!(title和alt除外)</h1> <h2>By [51js.com]zdzhuo</h2> <h2>Ie5.5+, Opera7.0, Netscap7.0, Mozilla1.4 都能正常使用</h2> <b>這是提示資訊</b><span>www.51js.com</span>不需要js就能實現的提示資訊<b>單純使用CSS實現提示資訊</b><span>一個非常簡便的方法原理也淺顯易懂</span><span>這是我在51js.com的專用頭像</span> </body>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.