我正在处理的网站上有一个部分,其中包含容器内的图像。我需要在图像上添加悬停状态,在图像上方的容器内显示带有薄边框的白色方块(下面的屏幕截图)。我遇到这个问题的原因是因为我已经在图像上有一个盒子阴影。我尝试将一个添加到图像周围的其他元素,但没有成功。如果有人能提供帮助那就太棒了!
它看起来像什么:
对悬停的期望效果:
HTML:
sun.misc
.opinion .atable .acell {
display: table-cell;
height: 100%;
width: 25%;
overflow: hidden;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border: 1px solid #ccc;
background-color: #fff;
outline: none;
vertical-align: top;
}
.opinion .atable .acell:hover {
-webkit-box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
-moz-box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
}
.opinion .atable .acell .contentbox {
position: relative;
}
.slideImg {
display: none;
}
.opinion .atable .acell .contentbox ul {
list-style-type: none;
}
.opinion .atable .acell .contentbox ul li a {
color: white;
display: block;
height: 200px;
max-width: 100%;
width: 100%;
background-size: cover;
background-position: center;
box-shadow: 0px 0px 0px 100px rgba(131, 141, 142, 0.7) inset;
}
.opinion .atable .acell .contentbox ul li a span {
position: absolute;
bottom: 0px;
left: 0px;
padding: 10px 10px 20px 10px;
color: #fff;
z-index: 10;
display: inline-block;
font-size: 1.3em;
text-shadow: 1px 1px 1px #000;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
border-top-left-radius: 4px;
}
.opinion .atable .acell .contentbox ul li a:after {
content: "";
position: absolute;
top: 0;
left: 0;
box-shadow: inset 0 0 0 350px blue;
width: 100%;
height: auto;
}
答案 0 :(得分:1)
我猜这是你想要的?
我已将CSS放在您的上方,无需再次在项目中复制您的CSS。顺便说一句,CSS中存在错误(-moz-border-radius-topleft
应为-moz-border-top-left-radius
)
div.opinion .atable .acell .contentbox ul {
padding: 0;
min-width: 40px;
widows: 100%;
margin: 0;
}
ul.slides:hover:after {
display: block;
width: calc(100% - 20px);
height: calc(100% - 20px);
left: 9px;
top: 9px;
position: absolute;
border: 1px solid white;
content: ' ';
}
.opinion .atable .acell .contentbox ul.slides a>span {
display: none;
}
.opinion .atable .acell .contentbox ul.slides:hover a>span {
position: absolute;
bottom: 0px;
left: 0px;
padding: 20px;
color: #fff;
z-index: 10;
display: inline-block;
}
/* code under this line is already in the project, you don't need it */
.opinion .atable .acell {
display: table-cell;
height: 100%;
width: 25%;
overflow: hidden;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border: 1px solid #ccc;
background-color: #fff;
outline: none;
vertical-align: top;
}
.opinion .atable .acell:hover {
-webkit-box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
-moz-box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
box-shadow: 0px 5px 7px 0px rgba(50, 50, 50, 0.25);
}
.opinion .atable .acell .contentbox {
position: relative;
}
.slideImg {
display: none;
}
.opinion .atable .acell .contentbox ul {
list-style-type: none;
}
.opinion .atable .acell .contentbox ul li a {
color: white;
display: block;
height: 200px;
max-width: 100%;
width: 100%;
background-size: cover;
background-position: center;
box-shadow: 0px 0px 0px 100px rgba(131, 141, 142, 0.7) inset;
}
.opinion .atable .acell .contentbox ul li a span {
position: absolute;
bottom: 0px;
left: 0px;
padding: 10px 10px 20px 10px;
color: #fff;
z-index: 10;
display: inline-block;
font-size: 1.3em;
text-shadow: 1px 1px 1px #000;
-webkit-border-top-left-radius: 4px;
-moz-border-top-left-radius: 4px;
border-top-left-radius: 4px;
}
.opinion .atable .acell .contentbox ul li a:after {
content: "";
position: absolute;
top: 0;
left: 0;
box-shadow: inset 0 0 0 350px blue;
width: 100%;
height: auto;
}
<div class="opinion">
<div class="atable">
<div class="acell">
<div class="contentbox">
<ul class="slides">
<li>
<a href="www.google.com" title="Permalink to Broadway Project" style="box-shadow: rgba(131, 140, 142, 0.701961) 0px 0px 0px 100px inset; background-image: url('http://www.ecdevelopment.org/wp-content/uploads/2015/04/hippie-flower.jpg');">
<img src="http://www.ecdevelopment.org/wp-content/uploads/2015/04/hippie-flower.jpg" class="slideImg wp-post-image" alt="broadwayproject2"><span>Broadway Project</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>