【问题标题】:How create this effect 3D with CSS3如何使用 CSS3 创建这种效果 3D
【发布时间】:2015-03-21 13:06:57
【问题描述】:

我想要制作的效果如下图所示:

http://i271.photobucket.com/albums/jj146/cosmossx/footer.jpg

正如您在此 FIDDLE

中所看到的,我已经取得了一些进展

css:

  .final{ background:#000;
  width:100%;}
  .triangle {
    border-color: white black black black;
    border-style: solid;
    border-width: 15px 25px 25px 25px;
    height: 0px;
    width: 500px;
    margin: 0 auto;
}

.triangle2 {
    border-color: black white white white;
    border-style: solid;
    border-width: 15px 25px 25px 25px;
    height: 0px;
    width: 500px;
    margin: 0 auto;
}

HTML:

<div class="final">  <div class="triangle"></div>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>

</div>
<div class="triangle2"></div>

我的问题是:最好的方法是什么?

谢谢。

【问题讨论】:

    标签: css transform shapes


    【解决方案1】:

    最好的方法是使用 css transform 函数和伪元素

    DEMO

    来源(为简洁起见,使用 Sass 和 Autoprefixer):

    <footer class="footer">
        <div class="footer__main">
              <div class="footer__inner">
                   <div class="footer__content">
                      <!-- content goes here -->
                   </div>
              </div>
        </div>
        <div class="footer__bottom"></div>
    </footer>
    

     

    .footer {
        height: 500px;
    }
    
    .footer__main {
        height: 80%;
        background: #eee;
    }
    
    .footer__bottom {
        height: 20%;
        background: darken(#eee, 20);
    }
    
    .footer__inner {
        background: white;
        max-width: 800px;
        margin: 0 auto;
        height: 100%;
        padding: 0 20px;
        position: relative;
    }
    
    .footer__content {
        background: #eee;
        height: 100%;
        transform: translateY(20px);
        position: relative;
        &:before,
        &:after {
            content: "";
            background: darken(#eee, 10);
            width: 20px;
            height: 100%;
            position: absolute;
            top: 0; bottom: 0;
            z-index: 2;
       }
       &:before {
            right: 100%;
            transform-origin: 100%;
            transform: skewY(45deg);
        }
        &:after {
            transform-origin: 0;
            left: 100%;
            transform: skewY(-45deg);
        }
    }
    

    【讨论】:

    • 对不起,我的名声很低
    • 哦,是的,你还不能投票。我忘记了。但您仍然可以接受作为问题作者的答案。
    • 抱歉耽搁了。非常感谢您的支持
    猜你喜欢
    • 2017-12-17
    • 1970-01-01
    • 2013-06-15
    • 2018-02-19
    • 2015-06-29
    • 2018-08-06
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    相关资源
    最近更新 更多