使用css裁剪照片

时间:2014-12-30 07:48:00

标签: html html5 css3

我需要为照片裁剪四边形。我需要平行四边形。但它是扭曲的。我需要一个平行四边形裁剪。我该怎么办?

代码如下:



img {
  transform: skew(-10deg);
  position:relative;
  left: 30px;
}

<img src="http://blogs.villagevoice.com/runninscared/RL%20Gang%20Boy.jpg">
&#13;
&#13;
&#13;

我想要的是我不希望男孩转身侧身但只想拍照。谢谢。

2 个答案:

答案 0 :(得分:1)

您可以使用svg的{​​{1}}和clipPathmaximum browser support应用内联foreignObject

clip-path

答案 1 :(得分:0)

请尝试这个css + html脚本

CSS

#graphic {
width: 200px;
height: 100px;
position: relative;
}

#graphic:before { 
content: '';    
position: absolute;
width: 200px;
height: 50px;
z-index: -1;

background-image: url(http://blogs.villagevoice.com/runninscared/RL%20Gang%20Boy.jpg`enter code here`); /* Image is 500px by 500px, but only 200px        by 50px is showing. */
}

HTML

<div id="graphic">lorem ipsum</div>