#gallery div::after {
content: "";
position: absolute;
top: 0;
}
#gallery div:hover::after {
background-image: url("files/img/plus.jpg") !important;
background-repeat: no-repeat;
height: 83px;
right: 0;
width: 83px;
transition: background 1300ms ease-in 2s;
}
#gallery a:nth-child(1) div {
background-image: url("files/img/bio/1.jpg");
background-size: cover;
height: 240px;
position: relative;
width: 240px;
}
我尝试向plus.jpg background-image
添加淡入淡出效果,并应用于::after
上的hover
伪元素。正如您所看到的,我尝试了transition: background 1300ms ease-in 2s
但没有发生任何事情......
Here您可以看到实时代码(是包含9张图片的图库。
答案 0 :(得分:-1)
试试这个。
#gallery div::after {
content: "";
position: absolute;
top: 0;
height: 83px;
right: 0;
width: 83px;
transition: opacity 1300ms ease-in 2s;
background-image: url("files/img/plus.jpg") !important;
background-repeat: no-repeat;
opacity: 0;
}
#gallery div:hover::after {
opacity: 1;
}
#gallery a:nth-child(1) div {
background-image: url("files/img/bio/1.jpg");
background-size: cover;
height: 240px;
position: relative;
width: 240px;
}
答案 1 :(得分:-1)
背景图片无法转换。但由于它只是一个简单的加号,我建议ff:
#gallery div::after {
background-color: #ddaa44;
color: white;
content: "+";
display: block;
font: 44px/44px verdana;
opacity: 0;
padding: 26px;
position: absolute;
right: 0;
top: 0;
}
#gallery div:hover::after {
opacity: 1;
transition: all 0.2s ease-in-out 0s;
}