html - 倾斜时保持图像不旋转?

标签 html css

我想剪切图像中的小元素。因此,我正在使用 skew 来执行此操作。

但是当倾斜时,图像似乎坏了,我想保持图像不旋转。

我的代码是这样的:

.image-skew{
/*   transform: skewX(-25deg); */
  position: absolute;
  width: 100%;
  height: auto;
}

.img-skew-invest {
  transform: skewX(-25deg);
  display: flex;
}
<div class="image-skew">
  <img class="img-skew-invest" src="http://thebusiness.vn/uploads/business360/chuyenkinhdoanh/lazada-co-noi-got-foodpanda-roi-khoi-viet-nam/lazada-co-noi-got-foodpanda-roi-khoi-viet-nam.png" alt="" style="width: 100%; height: auto"/>
</div>

相同的图像。

我截取了一个倾斜的图片元素,但应该不是旋转。

enter image description here

最佳答案

clip-path 将符合您的要求:

.image-skew {
-webkit-clip-path: polygon(25% 0, 100% 0, 100% 75%, 75% 100%, 0 100%, 0% 25%);
clip-path: polygon(25% 0, 100% 0, 100% 75%, 75% 100%, 0 100%, 0% 25%);
}

自己试试:https://jsfiddle.net/hgzsr5f5/1/或尝试剪辑路径生成器:http://bennettfeely.com/clippy/

关于html - 倾斜时保持图像不旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40544061/

相关文章:

php - 每个 div 和设计(完整网站)如果数据库有 1 行所有 div 打印 1 次,如果更多时间,则根据数据重复多个时间。为什么

css - 如何将 float : left? 的 div 的内容居中

Jquery 切换 html

javascript - 如何在 Bootstrap 中使用左右箭头按钮创建图像 slider

javascript - 使用java脚本在onClick事件中更改菜单选项卡的颜色

html - 如何创建圆点边框?

javascript用于根据php变量更改图像

javascript - 模态窗口将仅使用第一个元素打开,而不是第二个或第三个元素

html - ol 元素符号类型和文本 css

css - DIVs inside another DIV inside another DIV with CSS