Diagonal Side div color css js

后端 未结 3 1709
刺人心
刺人心 2021-01-25 13:06

i have 2 div like this

3条回答
  •  梦谈多话
    2021-01-25 13:48

    You can use clip paths and 2 div within a container,

    https://codepen.io/anon/pen/OOXPmv

    HTML

    CSS

    body, html {
      margin: 0;
      padding: 0;
      height: 100%;
      width: 100%;
      background: #ccc;
    }
    
    #wrapper {
      width: 100%;
      height: 100%;
      background: #111;
    }
    
    #left {
      position: absolute;
      top: 0;
      left: 0;
      width: 101%; /* If you make it 100%, you get a bit of black showing along the diagonal */
      height: 100%;
      background: #99b4d3;
      -webkit-clip-path: polygon(0 0, 76% 0, 24% 100%, 0% 100%);
      clip-path: polygon(0 0, 76% 0, 24% 100%, 0% 100%);
    }
    
    #right {
      position: absolute;
      top: 0;
      right: 0;
      width: 100%;
      height: 100%;
      background: #d9b596;
      -webkit-clip-path: polygon(76% 0, 100% 0, 100% 100%, 24% 100%);
      clip-path: polygon(76% 0, 100% 0, 100% 100%, 24% 100%);
    }
    

提交回复
热议问题