我的脑子疼,我不能让它起作用
我试图在这些盒子中添加内部阴影,使它们看起来与彼此的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;
}也许是电网出了问题?
发布于 2014-08-12 15:37:28
这与这样一个事实有关:当您将box-shadow应用于figure元素时,图像将位于其之上,并掩盖box-shadow。而且,据我所知,阴影不能直接应用于图像。
您可以使用: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;
}发布于 2014-08-12 08:56:22
你试过这样的东西吗?
<figure class="imgbox">
<div class="ImgShadow"></div>
<figcaption>
<h2><span>Coffe Name</span></h2>
<a href="#">View more</a>
</figcaption>
</figure>和CSS到ImgShadowclass:
.ImgShadow{
background:url("http://i.imgur.com/DTL3hGL.jpg");
height: 100%;
width: 100%;
box-shadow: inset 10px 10px 10px #FF0000,inset -10px -10px 10px #FF0000;
background-size:cover;
}小提琴
https://stackoverflow.com/questions/25258673
复制相似问题