Creating a diagonal line/section/border with CSS

前端 未结 6 1813
离开以前
离开以前 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:01

    With an svg, it is pretty simple :

    svg {
      display: block;
      width: 100%;
      height: 90px;
      background: yellow;
    }
    
      
    

    Note that I used the preserveAspectRatio="none" attribute so that the shape can have 100% width and keep 90px height

    And here with a monkey image :

    div {
      position: relative;
    }
    svg {
      display: block;
      width: 100%;
      height: 90px;
      background: yellow;
    }
    img {
      height: 50px;
      position: absolute;
      top: 0; bottom: 0;
      left: 0; right: 0;
      margin: auto;
      background: #fff;
      border-radius: 50%;
      padding: 10px;
    }

提交回复
热议问题