div+css 鼠标移到图片上显示文字内容

 时间:2026-02-12 01:40:31

1、首先输入:

<!DOCTYPE html> 

<html> 

<head> 

<meta charset="utf-8" /> 

<title>鼠标悬停图片上显示文字 在线演示 www.divcss5.com</title> 

<style> 

img{border:0}/* css 注释说明:设置图片边框为0 */ 

body{behavior:url("csshover.htc");text-align:center;}/* css注释说明:兼容ie6 支持标签使用hover */ 

div+css 鼠标移到图片上显示文字内容

2、然后输入:

.divcss5{ position:relative;width:554px; height:346px;margin:0 auto} 

.divcss5 a,.divcss5 span{display:none; text-decoration:none}

.divcss5:hover{cursor:pointer} 

.divcss5:hover a.now{cursor:pointer; position:absolute; top:0; width:100%; height:100%;z-index:100; left:0; display:block;}

.divcss5:hover span{ display:block;position:absolute; bottom:0; left:0;color:#FFF;width:554px; z-index:10;height:36px; line-height:36px; background:#000;filter:alpha(opacity=60);-moz-opacity:0.5;opacity: 0.5;}

/* 设置显示文字定位位置,背景半透明 */ 

div+css 鼠标移到图片上显示文字内容

3、然后输入:

</style> 

</head> 

<body> 

<div class="divcss5" style="background:url(imgexp.png)">

   <span>文字内容</span>

   <a href="#" class="now">&nbsp;</a>

</div> 

<div class="divcss5" style="background:url(imgexp.png)">

<span>欢迎访问DIVCSS5网站</span>

   <a href="http://www.divcss5.com/" class="now">&nbsp;</a> 

</div> 

</body> 

</html> 

div+css 鼠标移到图片上显示文字内容

4、然后就可以了。

div+css 鼠标移到图片上显示文字内容

  • a标签的下划线怎么去掉
  • 怎样让html中的文字垂直水平居中显示
  • HTML怎么添加滚动条
  • 如何让图片在div中居中显示
  • 通过CSS+DIV怎么将文字写在图片上方
  • 热门搜索
    体虚多汗怎么办 ps怎么改变图片颜色 taste怎么读 你怎么舍得我难过原唱 怀孕血糖高怎么办 螭吻怎么读 花甲怎么炒 离职原因怎么写最合适 头皮痒是怎么回事 怎么做动图