Adding a 45 degree angle to a container

前端 未结 4 1926
我在风中等你
我在风中等你 2020-12-22 07:29

I have a container element that I am trying to figure out if I can shape it to have two 45 degree angles. Like this:

It is simply a rectangle now:

<

4条回答
  •  感情败类
    2020-12-22 08:01

    #home-img-text-container {
      background: rgba(0,0,0,.8);
      padding: 30px 20px;
      position: relative;
    }
    
    #home-img-text-container:before,
    #home-img-text-container:after {
      position: absolute;
      content: '';
      display: block;  
      right: -40px;
      border: 40px solid transparent;
      border-right: 40px solid transparent;  
    }
    
    #home-img-text-container:before {
      top: 0;
      border-top: 40px solid white;  
    }
    
    #home-img-text-container:after {
      bottom: 0;
      border-bottom: 40px solid white;
    }
    
    #home-img-text-description {
      color: #FFF;
      font-size: 2.5em;
      line-height: 1.4em;
    }
    WRECKING
    & DEMOLITION
    DONE RIGHT.

提交回复
热议问题