CSS如何实现鼠标悬停在图片上底部弹出文字内容?

html-css059

CSS如何实现鼠标悬停在图片上底部弹出文字内容?,第1张

实现鼠标悬停在图片上底部弹出文字内容的实现方法:

HTML代码:

<div id="wrapper">

<img src="http://placehold.it/300x200" class="hover" />

<p class="text">text</p>

</div>

CSS代码:

#wrapper .text {

position:relative

bottom:30px

left:0px

visibility:hidden

}

#wrapper:hover .text {

visibility:visible

}

案例

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

.box {

width: 900px

background-color: #eee

border: 1px dashed #ccc

margin: 0 auto

}

.top {

height: 80px

}

.banner {

height: 120px

/*margin: 0 auto*/

margin: 5px auto

}

.main {

height: 500px

}

.footer {

height: 100px

/*margin: 0 auto

margin-top:5px*/

margin: 5px auto 0

}

</style>

</head>

<body>

<div class="top box">top</div>

<div class="banner box">banner</div>

<div class="main box"></div>

<div class="footer box"></div>

</body>

</html>

<HTML>

<HEAD>

<style type="text/css">

.cover{

font-size:14px

}

.cover:hover{

font-size:0px

}

.cover span{

display:none

}

.cover:hover span{

display:block

font-size:14px

}

</style>

</HEAD>

<BODY>

<a class="cover" href="#cover">测试<span>Test</span></a>

</BODY>

</HTML>