CSS Skew only container, not content

前端 未结 2 1433
梦毁少年i
梦毁少年i 2020-12-09 05:34

I\'m having trouble figuring out how to make the following layout work. I\'m not restricted to pure CSS - I know JS will be involved to make it cross-browser - but a CSS sol

2条回答
  •  盖世英雄少女心
    2020-12-09 06:09

    Need to tweak the positioning and the size of the container so you can crop it, and apply the backface-visibility rule:

    .skew {
        -webkit-backface-visibility : hidden; /* the magic ingredient */
        -webkit-transform           : skew(16deg, 0);
        overflow                    : hidden;
        width                       : 300px;
        height                      : 260px;
        position                    : relative;
        left                        : 50px;
        border                      : 1px solid #666
    }
    
    .skew img {
        -webkit-transform : skew(-16deg, 0);
        position          : relative;
        left              : -40px;
    }
    

    http://codepen.io/anon/pen/HLtlG <- before (aliased)

    http://codepen.io/anon/pen/wnlpt <- after (anti-aliased)

提交回复
热议问题