cai*_*ona 5 html css css3 css-transforms css-shapes
我正在尝试旋转我应用了"页面卷曲"投影的div.
页面卷曲阴影效果工作正常,直到我旋转div,此时阴影元素显示通过div(z-index问题)?
我也注意到,如果我有一个图像作为div内容,我不会遇到这个问题,但我很乐意让它适用于带有文本内容的div.有什么建议?
这是代码:
CSS(删除供应商前缀以缩短代码,但问题出现在所有现代浏览器中):
.shadow {border:1px solid #ccc;position:relative;width:300px;height:116px;background-color:#ededed;}
.shadow:before, .shadow:after {
bottom:13px;
content: "";
position: absolute;
z-index: -1;
-moz-transform: rotate(-11deg);
box-shadow: 0 15px 5px rgba(0, 0, 0, 0.2);
height: 50px;
max-width: 50%;
width: 50%;
left:3px;
}
.shadow:after {
-moz-transform: rotate(11deg);
left: auto;
right: 2px;
}
.rotate{
-moz-transform: rotate(4deg);
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="shadow">this is the first div</div> <!-- this one is ok -->
<div class="shadow rotate">this is the second div</div> <!-- this has the issue -->
<div class="shadow rotate"><img src="//www.google.com/logos/2012/Teachers_Day_Alt-2012-hp.jpg" width="300" height="116"></div> <!-- this one is ok -->
Run Code Online (Sandbox Code Playgroud)
这里有一个jsfiddle:http: //jsfiddle.net/U8qY3/5/
不错的工作!
作为一种解决方法,您可以在旋转的 div 内放置一个 DIV,将背景颜色设置为下方,并设置完整的高度和宽度,如下所示:http ://jsfiddle.net/U8qY3/6/
超文本标记语言
<div class="shadow rotate">
<div class="workaround">this is the second div</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.workaround{
height: 100%;
width: 100%;
background-color: #ededed;
}
Run Code Online (Sandbox Code Playgroud)