css3实现图片遮罩效果鼠标hover以后出现文字


Posted in HTML / CSS onNovember 05, 2013

鼠标hover 以后。图片上面出现一个遮罩, 透明度变化, 显示设置好的文字的文字,完全使用css 实现,下图是效果
css3实现图片遮罩效果鼠标hover以后出现文字 
关键代码

复制代码
代码如下:

.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="assets/img/1.jpg" class="attachment-thumbnail wp-post-image" alt="105694702"> </div>
<div class="content-wrap">
<h1 class="entry-title"><a href="" 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="assets/img/2.jpg" class="attachment-thumbnail wp-post-image" alt="105694702"> </div>
<div class="content-wrap">
<h1 class="entry-title"><a href="" class="featured-image" title="amp; Fashion" rel="bookmark">Music & Fashion</a></h1>
</div>
</div>
</article>
</div>
</body>
</html>
HTML / CSS 相关文章推荐
css3 条纹化和透明化表格Firefox下测试成功
Apr 15 HTML / CSS
简单掌握CSS3中resize属性的用法
Apr 01 HTML / CSS
CSS3 Notes: -webkit-box-reflect实现倒影的实例
Dec 08 HTML / CSS
html5使用Canvas绘图的使用方法
Nov 21 HTML / CSS
canvas学习笔记之2d画布基础的实现
Feb 21 HTML / CSS
HTML5移动端开发中的Viewport标签及相关CSS用法解析
Apr 15 HTML / CSS
HTML5拖放API实现拖放排序的实例代码
May 11 HTML / CSS
有关HTML5中背景音乐的自动播放功能
Oct 16 HTML / CSS
data:image data url 文件转为Blob上传后端的方法
Jul 16 HTML / CSS
html5移动端自适应布局的实现
Apr 15 HTML / CSS
关于webview适配H5上传照片或者视频文件的方法
Nov 04 HTML / CSS
css3的transition效果和transfor效果示例介绍
Oct 30 #HTML / CSS
CSS3之多背景background使用示例
Oct 18 #HTML / CSS
CSS3之背景尺寸Background-size使用介绍
Oct 14 #HTML / CSS
CSS3之边框多颜色Border-color属性使用示例
Oct 11 #HTML / CSS
CSS3文本换行word-wrap解决英文文本超过固定宽度不换行
Oct 10 #HTML / CSS
CSS3图片旋转特效(360/60/-360度)
Oct 10 #HTML / CSS
使用CSS3在触屏上为按钮实现激活效果
Sep 27 #HTML / CSS
You might like
php file_put_contents()功能函数(集成了fopen、fwrite、fclose)
2011/05/24 PHP
thinkPHP学习笔记之安装配置篇
2015/03/05 PHP
Laravel 5框架学习之Eloquent 关系
2015/04/09 PHP
php计划任务之验证是否有多个进程调用同一个job的方法
2015/12/07 PHP
详解PHP安装mysql.so扩展的方法
2016/12/31 PHP
PHP convert_uudecode()函数讲解
2019/02/14 PHP
地震发生中逃生十大法则
2008/05/12 Javascript
用js小类库获取浏览器的高度和宽度信息
2012/01/15 Javascript
javascript 事件处理程序介绍
2012/06/27 Javascript
得到jQuery detach()后节点中的某个值实现代码
2013/02/05 Javascript
js获取RadioButtonList的Value/Text及选中值等信息实现代码
2013/03/05 Javascript
JavaScript实现网页上的浮动广告的简单方法
2013/06/14 Javascript
Javascript页面添加到收藏夹的简单方法
2013/08/07 Javascript
全面了解javascript三元运算符
2016/06/27 Javascript
javascript类型系统——undefined和null全面了解
2016/07/13 Javascript
判断横屏竖屏(三种)
2017/02/13 Javascript
原生JavaScript实现remove()和recover()功能示例
2018/07/24 Javascript
详解Vue中watch的详细用法
2018/11/28 Javascript
webpack4 从零学习常用配置(小结)
2019/05/28 Javascript
[01:48]帕吉至宝加入游戏,遗迹战场现“千劫神屠”
2018/04/07 DOTA
python list语法学习(带例子)
2013/11/01 Python
python学习笔记:字典的使用示例详解
2014/06/13 Python
python相似模块用例
2016/03/04 Python
Python实现连接两个无规则列表后删除重复元素并升序排序的方法
2018/02/05 Python
Python 确定多项式拟合/回归的阶数实例
2018/12/29 Python
python字典的遍历3种方法详解
2019/08/10 Python
python shapely.geometry.polygon任意两个四边形的IOU计算实例
2020/04/12 Python
基于SpringBoot构造器注入循环依赖及解决方式
2020/04/26 Python
巴黎一票通:The Paris Pass
2018/02/10 全球购物
最经典的大学生职业生涯规划范文
2014/03/05 职场文书
2014年大学生四年规划书范文
2014/04/03 职场文书
公共场所禁烟标语
2014/06/25 职场文书
行风评议整改报告
2014/11/06 职场文书
云冈石窟导游词
2015/02/04 职场文书
草房子读书笔记
2015/06/29 职场文书
公务员岗前培训心得体会
2016/01/08 职场文书