【发布时间】:2018-11-06 14:07:43
【问题描述】:
编辑:
多亏了 tavkomann 的帮助,我的效果现在可以正常工作了。我还通过将每个图像容器的padding 设置为0px. 解决了我在下面划掉的问题,希望这对其他编码人员有所帮助!
只剩下一个问题:即使图像确实符合它们各自的容器并正确对齐,它们仍然没有跨越每个容器的整个宽度;结果,每边只剩下一条空间。
更新代码:
#main-imgs {
margin-top: 70px;
}
/* container for each image */
#main-imgs .img-column {
display: inline-block; /* conform container to image size */
overflow: hidden; /* avoid image-border overlap */
max-height: 215px;
padding: 0px; /* fit image within border */
border-width: 8px;
border-radius: 15%;
border-style: double;
border-color: #290B01;
box-shadow: 0px 0px 0px 0px black;
transition: all .6s ease-in-out;
}
/* container hover event */
#main-imgs .img-column:hover {
box-shadow: 0px 0px 30px 0px white;
transition: all .6s ease-in-out;
}
/* image */
#main-imgs img {
vertical-align: middle; /* rid of space beneath image */
opacity: 1.0;
transition: all .6s ease-in-out;
}
/* image hover event */
#main-imgs img:hover {
opacity: 0.2;
transition: all .6s ease-in-out;
}
原文:
我正在尝试让图像淡出并在您将鼠标悬停在黑色背景上时同时发光。
问题是当它淡出时,它的不透明度会降低,这会影响所有属性,包括box-shadow.
因此,发光效果的不透明度会降低并熄灭发光。到目前为止,当您将鼠标悬停在图像上方和远离图像时,图像会分别淡入和淡出。我在下面包含了 CSS 代码。
#main-imgs img {
max-height: 220px;
border-width: 8px;
border-radius: 15%;
border-style: double;
border-color: #290B01;
opacity: 1.0;
transition: all .6s ease-in-out;
}
#main-imgs img:hover {
opacity: 0.2;
transition: all .6s ease-in-out;
}
我有两种可能的(并发)解决方案,但还没有找到一种方法来实现:
- 在图像下方创建一个“底图”
div,使其散发出纯粹的光芒 - 使用除
hover伪类和opacity属性之外的东西来模拟和隔离淡入淡出效果(例如,使用jQuery)。
【问题讨论】:
标签: jquery image css opacity glow