【发布时间】:2016-04-16 22:42:26
【问题描述】:
我想制作这个效果:
悬停时的图像会变暗并稍微放大一点。我有效果,但我的初始图像被拉伸了。我不知道背景图片的大小,只希望在用户悬停时图片放大一点。
.highlight{
background-size: 100% 100%;
-moz-transition: background-size 3s ease, background-color 3s ease;
-webkit-transition: background-size 3s ease, background-color 3s ease;
transition: background-size 3s ease, background-color 3s ease;
}
.highlight:hover{
background-size: 120% 120%;
background-color:rgba(0,0,0,0);
-moz-transition: background-size 3s ease, background-color 3s ease;
-webkit-transition: background-size 3s ease, background-color 3s ease;
transition: background-size 3s ease, background-color 3s ease;
}
.highlight:hover:before{
content: "";
display: inline;
width: 100%;
height: 100%;
background-color:rgba(0,0,0,0.7);
-moz-transition: background-size 3s ease, background-color 3s ease;
-webkit-transition: background-size 3s ease, background-color 3s ease;
transition: background-size 3s ease, background-color 3s ease;
}
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="highlight" style="background-image:url(image-url)">
<div class="content">
<h3>Text</h3>
<p class="large">More text text text</a>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="highlight" style="background-image:url(image-url2)">
<div class="content">
<h3>Text2</h3>
<p class="large">More text text text2</a>
</div>
</div>
</div>
【问题讨论】: