【发布时间】:2018-09-29 18:06:04
【问题描述】:
我需要做一个我有图像的任务,这个图像被一些颜色淡化覆盖,当我将鼠标悬停在图像上时 - 淡化消失(例如 https://html5up.net/uploads/demos/forty/ )。我做到了,但我还必须做一个过渡,以便淡入淡出的消失会慢 2 秒。我试图将转换属性放在任何地方,但我失败了。请帮忙?
.photo-text.one {
background-size: cover;
background: url("https://i2.wp.com/www.thehopelesshousewife.com/wp-content/uploads/2013/12/Christmas-No-Bake-Nachos-576x409.jpg") no-repeat center top;
height: 409px;
position: relative;
width: 576px;
}
.img-overlay {
width: 100%;
height: 100%;
background: #6fc3df;
opacity: 0.75;
}
.photo-text.one:hover:after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: url("https://i2.wp.com/www.thehopelesshousewife.com/wp-content/uploads/2013/12/Christmas-No-Bake-Nachos-576x409.jpg") no-repeat center top;
}
.text {
position: absolute;
top: 100px;
left: 150px;
color: red;
z-index: 1;
}
<div class="photo-text one">
<div class="img-overlay"></div>
<h2 class="text">fffff</h2>
</div>
【问题讨论】:
标签: html css hover css-transitions