css实现带弧度的直角梯形

 

<div class="container"></div>
<style lang="scss">
.container {
  position: relative;
  width: 236px;
  height: 73px;

  &::before {
    position: absolute;
    content: '';
    top: 0;
    left: 0;
    width: 60px;
    height: 100%;
    transform: translateX(12px) skewX(-18deg);
    background-color: red;
    border-top-left-radius: 10px;
  }

  &::after {
    position: absolute;
    content: '';
    top: 0;
    right: 0;
    width: 180px;
    height: 100%;
    background-color: red;
    border-bottom-right-radius: 10px;
    border-top-right-radius: 10px;
  }
}
</style>

### Vue3实现直角长方形边框 CSS 样式 在 Vue3 项目中,可以通过简单的 CSS 属性来定义一个没有圆角的直角长方形边框样式。默认情况下,`border-radius` 设置为 `0` 可以确保边框不会有任何弧度。 以下是具体的代码示例: ```html <template> <div class="rectangle-box"> 这是一个直角长方形 </div> </template> <style scoped> .rectangle-box { width: 200px; height: 100px; border: 2px solid #e9e9e9; /* 定义边框宽度、样式和颜色 */ border-radius: 0; /* 确保无圆角效果 */ } </style> ``` 上述代码通过设置 `border` 和 `border-radius` 来创建一个标准的直角长方形边框[^1]。如果需要进一步调整边框的颜色或其他属性,可以直接修改对应的值。 #### 斜切效果扩展 对于更复杂的斜切效果,可以利用 `transform: skew()` 或者背景渐变的方式完成。例如,使用 `linear-gradient` 创建对角线样式的边框[^3]: ```css .rectangle-box { position: relative; width: 200px; height: 100px; } .rectangle-box::before { content: &#39;&#39;; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to left, transparent 50%, #e9e9e9 50%); z-index: -1; } ``` 此方法适用于需要视觉上呈现对角线条的情况。 --- #### 使用三角形技巧构建特殊形状 当需要构建有缺失部分的复杂图形时,可以借助 CSS 边框技巧生成三角形并组合成目标形状[^2]。例如,在 Vue 组件中实现类似两个直角梯形叠加的效果[^4]: ```html <template> <view class="flag-style"> <view class="flag-text">哈哈哈</view> </view> </template> <style scoped> .flag-style { position: relative; display: inline-block; margin-top: 50px; } .flag-text { padding: 10px 20px; font-size: 18px; color: white; background-color: blue; position: relative; } /* 左侧三角形 */ .flag-text::after { content: ""; position: absolute; top: 100%; left: 0; border-width: 15px; border-style: solid; border-color: blue transparent transparent transparent; } /* 右侧三角形 */ .flag-text::before { content: ""; position: absolute; top: 100%; right: 0; border-width: 15px; border-style: solid; border-color: blue transparent transparent transparent; } </style> ``` 以上代码展示了如何通过伪元素生成三角形,并将其附加到主要容器上来形成特定的几何结构。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值