鼠标悬浮链接弹出提示代码实例

快乐打工仔 分类:实例代码

分享一段代码实例,它实现了鼠标悬浮链接弹出提示的效果。

代码实例如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>前端教程网</title>
<style>
span{
  position: relative;
  display: inline-block;
}
span:hover{
  cursor: pointer;
}
span:hover:before{
  content: attr(data-showtip);
  background-color: #e1e1ea;
  color: #444;
  padding: .8em 1em;
  position: absolute;
  left: 100%;
  top: -70%;
  margin-left: 8px;
  white-space: pre; 
}
span:hover:after{
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-right: 8px solid #e1e1ea;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}
</style>
</head>
<body>
<span data-showtip="本站url是www.pipipi.net">前端教程网</span>
</body>
</html>

上面的代码实现了我们的要求,更多内容可以参阅相关阅读。

相关阅读:

(1).content可以参阅css content一章节。

(2). attr()可以参阅CSS attr()一章节。

回复

我来回复
  • 暂无回复内容