Split div with diagonal line

前端 未结 3 1273
[愿得一人]
[愿得一人] 2021-01-15 18:35

How would you split a div into 2 parts (both containing horizontal text) by a diagonal line?

e.g. see this where 1 has a rectangular background image and 2 has text

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 18:55

    .container {
      width: 400px;
      margin: 0 auto;
    }
    .box {
      width: 200px;
      height: 150px;
      text-align: center;
      float: left;
    }
    .box-1 {
      background: #ff4500;
    }
    .box-2 {
      background: #0ffab9;
    }
    .box-2:before {
      display: inline-block;
      margin: 0;
      margin-left: -101px;
      margin-top: -1px;
      position: absolute;
      content: '';
      width: 0;
    	height: 0;
    	border-bottom: 151px solid #0ffab9;
    	border-left: 30px solid transparent;
    }
    TITLE 1

提交回复
热议问题