Im trying to achieve something like this
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>
CSS clip-path Editor When using mouse, hold down Shift to lock x-axis or Alt to lock y-axis. Hold down shift while selecting a preset to only update animation-preview clip-path.
The clip-path CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the region are shown, while those outside are hidden.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With