将文本内容包裹在剪辑路径多边形(三角形)形状和另一半剪辑的图像中
Wrap text content inside a clip path polygon(triangle) shape and image clipped on other half
我正在努力实现这样的目标
我需要将一些文本和图像分成两半显示,如上图所示。
尝试使用 clip-path ,但文本内容没有换行,对齐也有问题。
我的代码:
.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>
这里需要 shape-outside:
.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>
您可以像下面这样减少代码:
.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>
我正在努力实现这样的目标
我需要将一些文本和图像分成两半显示,如上图所示。 尝试使用 clip-path ,但文本内容没有换行,对齐也有问题。
我的代码:
.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>
这里需要 shape-outside:
.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>
您可以像下面这样减少代码:
.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>