html怎么设置梯形背景颜色,设置css的border-color属性得到三角形或梯形

HTML(下面的效果图实现HTML的代码均一样)

JS Bin

1、CSS(中间有width,有height)

#wrapper{

width:100px;

height:100px;

border-width: 100px;

border-style: solid;

border-color: blue black red yellow;

}

效果图

ab1d406fed05

中间有width,有height

2、CSS(中间有width,无height)

#wrapper{

width:100px;

height:0;

border-width: 100px;

border-style: solid;

border-color: blue black red yellow;

}

效果图

ab1d406fed05

中间有width,有无height

3、CSS(中间无width,有height)

#wrapper{

width:0;

height:100px;

border-width: 100px;

border-style: solid;

border-color: blue black red yellow;

}

效果图

ab1d406fed05

中间无width,有height

4、CSS(中间无width,无height)

#wrapper{

width:0;

height:0;

border-width: 100px;

border-style: solid;

border-color: blue black red yellow;

}

效果图

ab1d406fed05

中间无width,无height

1、border-width:100px;设置元素边框上下左右宽度都是100px

2、border-color: blue black red yellow;设置元素四个边框的颜色

3、transparent : 颜色指定为透明的

利用上述出现情况和3个特点,那么我们就可以实现利用border-color属性获得不同角度的三角形和梯形。

5、CSS(中间无width,无height,三个边框颜色是transparent)

#wrapper{

width:0;

height:0px;

border-width: 100px;

border-style: solid;

border-color: transparent black transparent transparent;

}

效果图

ab1d406fed05

三角形实现

6、CSS(中间y有width,有height,三个边框颜色是transparent)

#wrapper{

width:100px;

height:100px;

border-width: 100px;

border-style: solid;

border-color:transparent transparent red transparent;

}

效果图

ab1d406fed05

梯形图实现

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值