【问题标题】:css page curl effect drop shadow with rotatecss页面卷曲效果阴影与旋转
【发布时间】:2012-10-16 14:18:32
【问题描述】:

我正在尝试旋转已应用“页面卷曲”投影的 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);
}

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 -->

这是一个 jsfiddle: http://jsfiddle.net/U8qY3/5/

【问题讨论】:

    标签: html css css-shapes css-transforms


    【解决方案1】:

    干得好!

    作为一种解决方法,您可以在旋转的 div 中放置一个 DIV,将背景颜色设置为下方,并设置完整的高度和宽度,如下所示:http://jsfiddle.net/U8qY3/6/

    HTML

    <div class="shadow rotate">
        <div class="workaround">this is the second div</div>         
    </div>
    

    CSS

    .workaround{
        height: 100%;
        width: 100%;
        background-color: #ededed;
    }
    

    【讨论】:

    • 就是这样!你们太了。它也适用于其他现代浏览器。
    • ps。我不能对巧妙的阴影效果赞不绝口。我在“互联网上”找到了它。
    猜你喜欢
    • 2023-04-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多