如何在CSS中创建不规则正方形? [英] How to create an irregular square shape in css?

查看:196
本文介绍了如何在CSS中创建不规则正方形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在寻找使用CSS制作这种特殊形状的代码.

Looking for the code to make this particular shape with CSS..

任何帮助,不胜感激!

推荐答案

您可以使用剪切路径.

clip-path CSS属性创建一个裁剪区域,该区域定义 应该显示元素的哪一部分.更具体地说,那些 显示了区域内部的部分,而外部的部分是 隐藏.

The clip-path CSS property creates a clipping region that defines what part of an element should be displayed. More specifically, those portions that are inside the region are shown, while those outside are hidden.

尝试此代码段.

div{
   width: 150px;
   height: 150px;
   -webkit-clip-path: polygon(5% 7%, 91% 14%, 98% 91%, 0% 100%);
   clip-path: polygon(5% 7%, 91% 14%, 98% 91%, 0% 100%);
   background: pink;
}

<div></div>

这篇关于如何在CSS中创建不规则正方形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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