本文主要是介绍CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
《CSS模拟html的title属性(鼠标悬浮显示提示文字效果)》:本文主要介绍了如何使用CSS模拟HTML的title属性,通过鼠标悬浮显示提示文字效果,通过设置`.tipBox`和`.tipBox.tipContent`的样式,实现了提示内容的隐藏和显示,详细内容请阅读本文,希望能对你有所帮助...
效果
原理
- 提示内容的定位:子绝父相
- 鼠标悬浮前,提示内容
visibility: hidden;
- 通过
:hover
触发鼠标悬浮样式,提示内容变为visibility: visible;
代码
<!DOCTYPE hChina编程tml> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>csspython 模拟 HTML title 效果(兼容php旧浏览器)</title> <style> /* 基本样式设置 */ .tipBox { position: relative; display: inline-block; } /* 定义提示框样式,初始隐藏 */ .tipBox .tipContent { position: absolute; top: 100%; left: 50%; color: rgb(javascript105, 100, 100); background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 2px; font-size: 12px; padding: 2px 4px; box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3); white-space: nowrap; visibility: hidden; } /* 鼠标悬停时显示提示框 */ .tipBox:hover .tipContent { visibility: visible; } </style> </head> <body> <h1>title 效果</h1> <div title="CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)">12345678</div> <h1>css 模拟 title 效果</h1> <div class="tipBox"> 12345678 <div class=编程"tipContent">12345678</div> </div> </body> </html>
到此这篇关于CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)的文章就介绍到这了,更多相关css html title属性内容请搜索编程China编程(www.chinasem.cn)以前的文章或继续浏览下面的相关文章,希望大家以后多多支持China编程(www.chinasem.cn)!
这篇关于CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!