手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >css3实现图片遮罩效果鼠标hover以后出现文字
css3实现图片遮罩效果鼠标hover以后出现文字
摘要:鼠标hover以后。图片上面出现一个遮罩,透明度变化,显示设置好的文字的文字,完全使用css实现,下图是效果关键代码.featured-im...

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

1

关键代码

.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>

<div>

<div> <img width="480" height="640" src="assets/img/1.jpg" alt="105694702"> </div>

<div>

<h1><a href="" rel="bookmark">Music & Fashion</a></h1>

</div>

</div>

</article>

<article>

<div>

<div> <img width="480" height="640" src="assets/img/2.jpg" alt="105694702"> </div>

<div>

<h1><a href="" title="amp; Fashion" rel="bookmark">Music & Fashion</a></h1>

</div>

</div>

</article>

</div>

</body>

</html>

【css3实现图片遮罩效果鼠标hover以后出现文字】相关文章:

怎样用CSS实现大背景网页效果

纯CSS无表达式实现未知尺寸图片等比缩放(支持IE7及以上)

巧用CSS3 border实现图片遮罩效果代码

css实现鼠标滑过改变文字(中文变英文)

一款css实现的鼠标经过按钮的特效

一款纯css实现的垂直时间线效果

纯CSS结合DIV实现的右侧底部简洁悬浮效果

利用css实现图片等比例缩放

纯CSS实现鼠标悬停提示的方法

用css实现文字的自动隐藏

精品推荐
分类导航