【发布时间】:2016-10-01 16:57:57
【问题描述】:
请查看此代码:http://codepen.io/Varin/pen/kkGgVd
<div class="container">
<div class="outside2">
<div class="inside2">
<span class="text"></span>
</div>
</div>
<div class="outside2">
<div class="inside2">
<span class="text"></span>
</div>
</div>
<div class="outside2">
<div class="inside2">
<span class="text"></span>
</div>
</div>
</div>
还有 CSS
$color1 : rgba(123,223,12,0.66);
$color2 : rgba(23,43,122,0.66);
body {
box-sizing: border-box;
background-color: #222222;
display:flex;
flex-direction:column;
justify-content: center;
align-items: center;
//height: 100vh;
font-family: 'Josefin Sans', sans-serif;
font-weight: 400;
}
.container {
display:flex;
}
.text:after {
content: 'Some info about the product and features, the history of the company lorem ipsum and so on.';
}
.outside2 {
margin: 10px;
box-sizing: border-box;
padding: 10px;
display:flex;
justify-content: center;
align-items: center;
text-align: center;
background: url(https://image.freepik.com/free-vector/wavy-letter-v-logo-in-abstract-style_1017-1976.jpg);
background-position: center center;
background-size: cover;
height: 200px;
width: 200px;
border: solid 0px rgba(0,0,0,0.4);
transition-duration: 0.5s;
&:hover {
box-shadow: inset 0px 0px 101px 100px $color1, 0px 0px 201px 56px $color1;
.text {
opacity:1;
transition-delay: 0.2s;
}
}
.text {
color: #fff;
opacity:0;
transition-duration: 0.5s;
transition-delay: 0.1s;
}
}
在悬停时显示两种类型的框阴影的最后一行,第一个元素的阴影位于第二个元素下方。只有第 3 个元素的阴影显示在第 2 个元素上。
我想我可以使用 z-index,但是有没有办法确保所有的 box-shadow 总是在其他所有东西之上?这和flexbox有关吗?
【问题讨论】:
-
只需将
z-index: 1添加到.outside2:hover。您不需要任何 CSS 定位。 -
谢谢,将 z-index:1 添加到 :hover 效果很好。这实际上解决了我的很多问题。还在学习中。
标签: html css hover flexbox box-shadow