9

Im trying to achieve something like this enter image description here

I need to display some text and an image in two halves like shown in the above image. Tried to use clip-path ,but the text content is not wrapped and have issues with alignment too.

My code:

.clipped-text{
  width: 250px; height: 250px;
  background: #1e90ff;
  clip-path: polygon(0 100%, 100% 100%, 0 0);
  text-align: justify;
  position: absolute;

}

.clipped-image{
  width: 250px; height: 250px;
  background: #1e90ff;
  clip-path: polygon(100% 100%, 100% 0, 0 0);
  text-align: justify;
   position: absolute;

}
<div>
 <img class="clipped-image" src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png"/>
 <p class="clipped-text">
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
</p>
</div>
Yashwanth Kata
  • 817
  • 8
  • 21

1 Answers1

6

You need shape-outside here:

.box {
  width: 300px;
  height: 300px;
  background: #1e90ff;
  text-align: justify;
}

.clipped-image {
  float:right;
  width: 100%;
  height: 100%;
  background: #1e90ff;
  shape-outside: polygon(100% 100%, 100% 0, 0 0);
  clip-path:     polygon(100% 100%, 100% 0, 0 0);
}
<div class="box">
  <img class="clipped-image" src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png" />
  <p class="clipped-text">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  </p>
</div>

You can reduce the code like below:

.clipped-text  {
  width: 300px;
  height: 300px;
  background: #1e90ff;
  text-align: justify;
}

.clipped-text:before {
  content:"";
  float:right;
  width: 100%;
  height: 100%;
  background: url(https://picsum.photos/id/1069/400/400) center/cover;
  shape-outside: polygon(100% 100%, 100% 0, 0 0);
  clip-path:     polygon(100% 100%, 100% 0, 0 0);
}
<p class="clipped-text">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  </p>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415