Creating a diagonal line/section/border with CSS

前端 未结 6 1789
离开以前
离开以前 2020-12-07 23:34

I am trying to create a diagonal line on a webpage, to act as a section/section break. This is essentially a split colour section. I cant use an image as if the page gets en

6条回答
  •  不思量自难忘°
    2020-12-08 00:20

    You can do this using a gradient.

    body {
      height: 200px;
      margin: 0 0 20px 0;
      background-color: transparent;
      background-size: 20px 20px;
      background-image:
         -webkit-repeating-linear-gradient(-45deg, black, black 1px, transparent 1px, transparent 14px);
      background-image:
         -moz-repeating-linear-gradient(-45deg, black, black 1px, transparent 1px, transparent 14px);
      background-image:
         -o-repeating-linear-gradient(-45deg, black, black 1px, transparent 1px, transparent 14px);
      background-image:
         repeating-linear-gradient(-45deg, black, black 1px, transparent 1px, transparent 14px);
    }
    

    JSFiddle

提交回复
热议问题