gpt4 book ai didi

css - 环绕 div 的文本

转载 作者:太空狗 更新时间:2023-10-29 13:27:18 28 4
gpt4 key购买 nike

如果您想要容器底部的 div,如何让文本环绕 div

我可以弄清楚如何让文本环绕在 div 上,只要它在顶部,但如果我尝试将它推到页面底部,文本要么不会'不要继续跨越 div 的顶部,否则 div 会被推到文本前面。

目前,我有一个容器 div,然后黑框是该 div 中的另一个 div。

我正在尝试创建这个:

最佳答案

您只需要使用 float 属性即可。

HTML:

<div>
<img src="http://www.igta5.com/images/trailer-2-gtav-logo.jpg" alt="GTA V" />
<p>
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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>

CSS:

div img {
width: 240px;
float: right;
padding: 25px;
}

Play with this on jsFiddle.


更新

使用纯 CSS,您最多只能使用绝对定位手动分隔图像的两侧。

HTML:

<div class="left">
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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="right">
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. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<img src="http://www.igta5.com/images/trailer-2-gtav-logo.jpg" style="width: 240px; height: 140px;">

CSS:

img {
position: absolute;
top: 0;
left: 50%;
margin-left: -125px;
margin-top: 60px;
}

.left, .right {
width: 49%;
}

.left {
float: left;
}
.right {
float: right;
}

.left:before, .right:before {
content: "";
width: 125px;
height: 200px;
}

.left:before {
float: right;
}

.right:before {
float: left;
}

Play with this on jsFiddle.

更多信息

您可以在 this topic, on StackOverflow 中找到更多信息.

关于css - 环绕 div 的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17558033/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com