HTML标记:
<div class="item">
<a href="url">
<img src="photo.jpg" />
</a>
</div>
此CSS在悬停时缩放图像:
.item a img {
transition: all 0.2s linear;
}
.item a:hover img {
transform: scale(1.05);
}
此CSS在悬停时添加了叠加层:
.item a {
position: relative;
}
.item a:before {
content: "";
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: none no-repeat center center;
transition: all .3s linear;
}
.item a:hover:before {
background:rgba(0,0,0, 0.5) url('img/zoom.png') no-repeat center center;
}
每个人本身都很好。但是,当我尝试使用两个CSS时,只有缩放工作;叠加层坏了。
简单地说,如何编写CSS来组合这两种效果?
答案 0 :(得分:3)
您可以尝试将private class WaitSec extends AsyncTask<Void, Void, Boolean>{
@Override
protected Boolean doInBackground(Void... params) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(CheckSomeUtil.isItOk()) {
return true;
} else {
return false;
}
}
@Override
protected void onPostExecute(Boolean aBoolean) {
if(aBoolean)
// in this line. is i want to set listener.
super.onPostExecute(aBoolean);
}
}
添加到绝对定位元素。
z-index:1
.item a img {
transition: all 0.2s linear;
}
.item a:hover img {
transform: scale(1.05);
vertical-align: top;
}
.item a {
position: relative;
display: inline-block;
}
.item a:before {
content: "";
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: none no-repeat center center;
transition: all .3s linear;
z-index: 1;
}
.item a:hover:before {
background: rgba(0, 0, 0, 0.5) url('//dummyimage.com/50') no-repeat center center;
}