css怎么绘制斜线


本文摘自PHP中文网,作者anonymity,侵删。

使用单个标签,如何实现下图所示的斜线效果。也就是如何使用 CSS 画斜线?

我们假定我们的 HTML 结构如下:

1

<div></div>

法一、CSS3 旋转缩放

这里我们使用 伪元素 画出一条直线,然后绕 div 中心旋转 45度 ,再缩放一下就可以得到。

具体实现css代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

div{

  position:relative;

  margin:50px auto;

  width:100px;

  height:100px;

  box-sizing:border-box;

  border:1px solid #333

  // background-color:#333;

  line-height:120px;

  text-indent:5px;

}

div::before{

  content:"";

  position:absolute;

  left:0;

  top:0;

  width:100%;

  height:50px;

  box-sizing:border-box;

  border-bottom:1px solid deeppink;

  transform-origin:bottom center;

  // transform:rotateZ(45deg) scale(1.414);

  animation:slash 5s infinite ease;

}

@keyframes slash{

  0%{

    transform:rotateZ(0deg) scale(1);

  }

  30%{

    transform:rotateZ(45deg) scale(1);

  }

  60%{

    transform:rotateZ(45deg) scale(1.414);

  }

  100%{

    transform:rotateZ(45deg) scale(1.414);

  }

}

法二、线性渐变实现

阅读剩余部分

相关阅读 >>

css id选择器怎么写

如何在css上让图片居中、图片适应

css怎么让超链接不可用

什么是对html的补充,可以使网页形式和内容分离?

css怎么让div隐藏

css text-decoration属性怎么用

css如何实现按钮居中显示

清除浮动的css写法有哪些

css 伪类有哪些

了解css的选择器优先级和!important权重

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...