css实现鼠标悬停时滑出层提示

2017-05-12

学习前端的小伙伴们你们知道怎么用css实现鼠标悬停时滑出层提示的方法吗?不知道的话跟着小编一起来学习怎么用css实现鼠标悬停时滑出层提示。

css实现鼠标悬停时滑出层提示的方法介绍

这是一个简单的鼠标悬停提示特效,类似于alt标签,不过这一种是用纯CSS实现,扩展性好,而且在提示的层里可以加入图片或其它布局,这个要根据你的需要了。

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="//www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>css实现层提示</title>

<style>

div{

clear:both;

margin:5px 0 0 0;

font-size:12px;

line-height:22px;

}

a.alt{

position:relative;

background-color:#fff;

float:left;

width:158px;height:20px;

margin:0 auto;

border:1px solid #eee;

text-align:center;

text-decoration:none;

color:#0066cc;

}

a.alt:hover{

background:#fff;

text-decoration:none;z-index:2;

}

a.alt span{

display:none;

}

a.alt:hover span{

position:absolute;

display:block;

top:-1px;left:158px;

width:130px;height:60px;

border:1px solid #eee;

z-index:1;

}

</style>

</head>

<body>

<div>

<a class='alt' href="/"><span>一资料网站</span></a>

</div>

<div>

<a class='alt' href="/"><span>给你实用的CSS代码</span>网页特效库</a>

</div>

</body>

</html>

更多相关阅读

最新发布的文章