Search code examples
csssvgbackgroundopacity

Slant on background image with opacity


I am making a One-Page webstie to practise Flexbox etc.

To do that, Im using PSD file and I have some troubles. I wanna make rectangle with an oblique upper side with opacity on my background, i read about svg and should I do it with that like on this picture:

(brown thing with opacity throughout the website view)

I have again similar problem. I have a pic: enter image description here

And it should looks like:enter image description here

Tips will be great


Solution

  • Another approach without gradient.

    Create a wrapper It can be the div with background image. Important thing is you need to overflow: hidden and position: relative.

    Create a rectangle and rotate it You can create a :before pseudo element like this:

    .wrapper {
      position: relative;
      width: 100%;
      height: 200px;
      background: red;
      overflow: hidden;
    }
    
    .wrapper:before {
      content: '';
      position: absolute;
      display: block;
      background: blue;
      opacity: .5;
      bottom: -100px;
      left: -100px;
      right: -100px;
      height: 150px;
      transform: rotate(-5deg);
    }
    <div class="wrapper"></div>