css类似环绕效果
CSS环绕效果可以使用CSS的position属性和z-index属性来创建。下面是一个简单的示例:
HTML代码:
<div class="wrapper">
<img src="image.jpg" alt="Image">
<div class="text">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
CSS代码:
.wrapper {
position: relative;
display: inline-block;
}
img {
float: left;
margin-right: 20px;
}
.text {
position: absolute;
top: 0;
left: 0;
z-index: 1;
background-color: rgba(255, 255, 255, 0.8);
padding: 10px;
}
在这个例子中,wrapper div包含了一个图片和一个文本块。图片是使用float属性向左浮动的,而文本块则使用position和z-index属性来将其放置在图片之上。通过设置文本块的背景色和透明度,可以创建一个类似于环绕效果的外观
原文地址: https://www.cveoy.top/t/topic/g1NU 著作权归作者所有。请勿转载和采集!