CSS变形将形状扭曲为梯形 [英] CSS Transform to skew the shape to a trapezium

查看:3039
本文介绍了CSS变形将形状扭曲为梯形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要能够以图像显示在下面的方式扭曲元素。

I want to be able to skew an element in the way the image displays below.

我一直在玩,但似乎不能接近复制的形状。

I have been playing around with it, but dont seem to be able to get close to replicating that shape.

我的css代码是

transform:skew(30deg,30deg);

转换甚至是正确的方法吗?

Is transform even the right way to do this? Please let me know the best, most browser compatible, solution.

推荐答案

您可以对X轴应用一些旋转变换,然后应用之前的

You can apply some rotate transform around the X axis and apply an appropriate pespective before:

div {    
  width:300px;
  height:200px;
  background:url(http://placekitten.com/300/200);
  border:2px solid red;    
  border-top-width:4px;
  border-bottom-width:1px;
  -webkit-transform: perspective(200px) rotateX(40deg);    
  margin:100px;
}

这篇关于CSS变形将形状扭曲为梯形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆