0

I'm trying to create this:

Image with slanted square overlay

I can't manage to get a slight slant. I'm able to achieve a triangle with changing the borders, but It's slanted too much.

Here is my code for the image with a square and the text:

.realtor-img-background {
    height: 400px;
    width: 450px;
    background: url("./images/real-estate.jpg");
}
.square{
    position: absolute;
    bottom:0;
    height: 200px;
    width: 450px;
    background-color: red;
}
<div class="realtor-img-background">
 <div class="square">
     <h3 class="eva-text-white">
        Realtors
        </h3>
     <p class="eva-text-white">
            Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
        </p>
    </div>
</div>
G. Gary
  • 25
  • 7

1 Answers1

2

You can create this shape by using CSS pseudo elements with the help of Border

.realtor-img-background {
  height: 400px;
  width: 450px;  
  position: relative;
  background: url("http://via.placeholder.com/350x150") no-repeat top center;
  background-size: cover;
}

.square {
  position: absolute;
  bottom: 0;
  background-color: red;
}

.square:before {
    content: "";
    position: absolute;
    left: 0;
    top: -100px;
    border-style: solid;
    z-index: 1;
    width: 0;
    height: 0;
    border:0;
    border-bottom: 100px solid red;
    border-right: 450px solid transparent;
}
<div class="realtor-img-background">
  <div class="square">
    <h3 class="eva-text-white">
      Realtors
    </h3>
    <p class="eva-text-white">
      Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
    </p>
  </div>
</div>
Ismail Farooq
  • 6,309
  • 1
  • 27
  • 47