css3实现图片遮罩效果鼠标hover以后出现文字
前端  /  管理员 发布于 7年前   349
鼠标hover 以后。图片上面出现一个遮罩, 透明度变化, 显示设置好的文字的文字,完全使用css 实现,下图是效果 
 
关键代码 
复制代码代码如下: 
.featured-image:hover { 
opacity: 0.9; 
color: #fff; 
background: rgba(0,0,0,0.8); 
} 
看源码吧 
复制代码代码如下: 
<!doctype html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>无标题文档</title> 
<style> 
#content article { 
float: left; 
margin-right: 4%; 
max-width: 236px; 
position: relative; 
width: 22%; 
margin-bottom: 3.5%; 
} 
#content article:nth-child(4n+4) { 
margin-right: 0; 
} 
.post-format-content { 
position: relative; 
background: #111; 
} 
.post-thumbnail { 
max-width: 100%; 
height: auto; 
overflow: hidden; 
} 
.content-wrap { 
padding: 0; 
position: absolute; 
text-align: center; 
width: 100%; 
top: 0; 
bottom: 0; 
display: table-cell; 
vertical-align: middle; 
overflow: hidden; 
} 
.content-wrap h1.entry-title { 
display: table; 
font-size: 110%; 
height: 100%; 
text-transform: uppercase; 
width: 100%; 
margin:0; 
} 
.edit-link { 
z-index: 2; 
} 
.featured-image { 
display: table-cell; 
position: relative; 
transition: opacity .25s ease-in-out, background .25s ease-in-out; 
-moz-transition: opacity .25s ease-in-out, background .25s ease-in-out; 
-webkit-transition: opacity .25s ease-in-out, background .25s ease-in-out; 
vertical-align: middle; 
z-index: 1; 
color: #fff; 
text-decoration: none; 
opacity: 0; 
padding: 10%; 
} 
.featured-image:hover { 
opacity: 0.9; 
color: #fff; 
background: rgba(0,0,0,0.8); 
} 
.post-thumbnail img { 
display: block; 
} 
img { 
max-width: 100%; 
height: auto; 
} 
</style> 
</head> 
<body> 
<div id="content"> 
<article class="post-152 post type-post status-publish format-standard hentry category-people category-photos"> 
<div class="post-format-content"> 
<div class="post-thumbnail"> <img width="480" height="640" src="https:/css/assets/img/1.jpg" class="attachment-thumbnail wp-post-image" alt="105694702"> </div> 
<div class="content-wrap"> 
<h1 class="entry-title"><a href="https:/css/" class="featured-image" rel="bookmark">Music & Fashion</a></h1> 
</div> 
</div> 
</article> 
<article class="post-152 post type-post status-publish format-standard hentry category-people category-photos"> 
<div class="post-format-content"> 
<div class="post-thumbnail"> <img width="480" height="640" src="https:/css/assets/img/2.jpg" class="attachment-thumbnail wp-post-image" alt="105694702"> </div> 
<div class="content-wrap"> 
<h1 class="entry-title"><a href="https:/css/" class="featured-image" title="amp; Fashion" rel="bookmark">Music & Fashion</a></h1> 
</div> 
</div> 
</article> 
</div> 
</body> 
</html> 
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
			Copyright·© 2019 侯体宗版权所有·
			粤ICP备20027696号
			 
			
