You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在div中切除矩形双上角以实现房屋形状?

实现带切角的房屋形状Div

直接用clip-path的polygon()函数就能实现你要的效果,下面是调整后的代码:

<!-- 顶部带切角的房屋形状div -->
<div style="max-width: 600px; height: 700px; background-color: #ffdbbb; padding: 10px; border-bottom-right-radius: 50px; 
clip-path: polygon(50px 0, calc(100% - 50px) 0, 100% 50px, 100% 100%, 0 100%, 0 50px);"></div>

参数说明:

  • 50px 0 和 calc(100% - 50px) 0:定义顶部两个切角的顶点,数值越大,切角的横向宽度越宽
  • 100% 50px 和 0 50px:定义左右两侧和顶部切角的连接点,数值越大,切角的纵向高度越高
  • 可根据需求调整这些50px的数值,改变切角的大小和形状

你之前没成功应该是没正确设置polygon的顶点顺序,clip-path需要按顺时针或逆时针顺序依次定义形状的所有顶点,才能正确渲染出目标图形。

内容的提问来源于stack exchange,提问作者Honey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 12:22:12