gpt4 book ai didi

jquery - 如何为网格中的图像添加内部阴影?

转载 作者:太空宇宙 更新时间:2023-11-04 13:04:06 24 4
gpt4 key购买 nike

我的脑袋疼,我无法让它工作

我正在尝试为这些盒子添加内部阴影,使它们看起来彼此分离 http://i.imgur.com/RlClNbh.png

http://jsfiddle.net/96d7udd7/

我试过这个

img { 
box-shadow: inset 0px 0px 10px rgba(0,0,0,0.5);
}

但它只给标志一个内部阴影而不是盒子里的图像


这是盒子的HTML

    <figure class="imgbox">
<img src="img/1.jpg" height="400px" alt="image01"/>
<figcaption style="background: rgb(53, 25, 10)">
<h2><span>Coffe Name</span></h2>
<a href="#">View more</a>
</figcaption>
</figure>

和 CSS

    figure.imgbox figcaption {
box-shadow: inset 0px 0px 10px rgba(0,0,0,0.5);
top: auto;
bottom: 0;
padding: 1em;
height: 3.75em;
background: #fff;
color: #fff;
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: translate3d(0,100%,0);
transform: translate3d(0,100%,0);
}

figure.imgbox h2 {
float: center;
}

figure.imgbox figcaption > span {
float: center;
}

figure.imgbox p {
position: absolute;
bottom: 8em;
padding: 2em;
color: #fff;
text-transform: none;
font-size: 90%;
opacity: 0;
-webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
}

figure.imgbox h2,
figure.imgbox figcaption > span {
-webkit-transition: -webkit-transform 0.35s;
transition: transform 0.35s;
-webkit-transform: translate3d(0,200%,0);
transform: translate3d(0,200%,0);
}

figure.imgbox figcaption > span::before {
display: inline-block;
padding: 8px 10px;
font-family: 'feathericons';
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.icon-eye::before {
content: '\e000';
}

.icon-paper-clip::before {
content: '\e001';
}

.icon-heart::before {
content: '\e024';
}

figure.imgbox h2 {
display: inline-block;
}

figure.imgbox:hover p {
opacity: 1;
}

figure.imgbox:hover figcaption,
figure.imgbox:hover h2,
figure.imgbox:hover figcaption > span {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}

figure.imgbox:hover h2 {
-webkit-transition-delay: 0.05s;
transition-delay: 0.05s;
}

figure.imgbox:hover figcaption > span:nth-child(4) {
-webkit-transition-delay: 0.1s;
transition-delay: 0.1s;
}

figure.imgbox:hover figcaption > span:nth-child(3) {
-webkit-transition-delay: 0.15s;
transition-delay: 0.15s;
}

figure.imgbox:hover figcaption > span:nth-child(2) {
-webkit-transition-delay: 0.2s;
transition-delay: 0.2s;
}

可能是网格有问题?

最佳答案

这与以下事实有关:当您将 box-shadow 应用于 figure 元素时,图像会位于它之上并遮挡 盒子阴影。此外,据我所知,阴影不能直接应用于图像。

您可以使用 :before 规则来解决这个问题,或者您可以将图像作为 background-image 应用到 figure并将 box-shadow 也应用于此元素。

:before 的 css,保持你的标记不变,将是这样的:

.imgbox:before {
content: "";
height: 100%;
width: 100%;
position: absolute;
box-shadow: inset 0px 0px 10px rgba(0, 0, 0, 1);
z-index: 2;
}
.imgbox img {
position:relative;
z-index:1;
}

关于jquery - 如何为网格中的图像添加内部阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25258673/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com