在html中如何画斜线,在CSS中绘制斜线

您可以通过使用偏斜变换(transform:skew(Xdeg))在CSS中创建有角度的线.以下是一个示例代码段:

.shape {

height: 50px;

width: 200px;

border-bottom: 2px solid red;

border-right: 2px solid red;

-moz-transform: skew(-45deg);

-webkit-transform: skew(-45deg);

transform: skew(-45deg);

}

如果在下面的代码片段中使用单个元素(和几个伪元素),也可以使用一个在内容区域上方的一行和一个后面的一行:

.shape:before {

position: absolute;

bottom: -5px;

left: -5px;

content: '';

height: 50px;

width: 100%;

border-bottom: 3px solid red;

border-right: 4px solid red;

-webkit-transform: skew(-45deg);

-moz-transform: skew(-45deg);

transform: skew(-45deg);

}

.shape:after {

position: absolute;

content: '';

bottom: -10px;

left: 0px;

height: 55px;

width: 100%;

border-bottom: 3px solid red;

border-right: 4px solid red;

-webkit-transform: skew(-45deg);

-moz-transform: skew(-45deg);

transform: skew(-45deg);

z-index: -1;

}

.shape {

position: relative;

height: 80px;

width: 400px;

background: whitesmoke;

}

Some text that goes within the element...

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值