您当前的位置:首页 > 计算机 > 编程开发 > Html+Div+Css(前端)

CSS实现梯形

时间:12-09来源:作者:点击数:

本质上就是设置了3个方向的边框border,其中两个方向的border为透明色。

1.横向梯形

<div class="div1"></div>
<div class="div2"></div>

<style>
       .div1{
            width:100px;
            height: 0;
            border-bottom: 20px solid #000;
            border-left: 15px solid transparent;
            border-right: 15px solid transparent;
        }
        .div2{
            width:100px;
            height: 0;
            border-top: 20px solid #000;
            border-left: 15px solid transparent;
            border-right: 15px solid transparent;
        }
</style>

效果图:

image

2.纵向梯形

<div class="div3"></div>
<div class="div4"></div>

<style>
      .div3{
            width:0;
            height: 100px;
            border-left: 20px solid #000;
            border-top: 15px solid transparent;
            border-bottom: 15px solid transparent;
        }
        .div4{
            width:0;
            height: 100px;
            border-right: 20px solid #000;
            border-top: 15px solid transparent;
            border-bottom: 15px solid transparent;
        }
</style>

效果图:

image
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐