gpt4 book ai didi

html - 为什么我的文字折叠成 4 行?

转载 作者:太空宇宙 更新时间:2023-11-03 19:56:44 25 4
gpt4 key购买 nike

代码:

#a {
position: absolute;
left: 100px;
}

#b {
position: absolute;
left: 200px;
top: 100px;
}
<div id="a">
test test test test<span id="b">xxxx xxxx xxxx xxxx</span>
</div>

结果是这样的:

          test test test test

xxxx
xxxx
xxxx
xxxx

你可以看到我的“xxxx”文本折叠成 4 行。

但我想要的是:

          test test test test

xxxx xxxx xxxx xxxx

所以我的问题是:

  1. 为什么我的文本折叠成 4 行而不是 1 行?
  2. 如何达到我想要的结果?

编辑:

正如@Manish Dalal 所言,这是一种非常奇怪的行为:

Is there any CSS rule applied on div or width of any of the parent is limited?

If I copy only this code (as is) on an HTML page, I can see what you wish to achieve. So I assume that some parent control that have position relative and have limited width (by itself or due to its parents') and hence have limited the width of the div. (As by default a div will take all the horizontal spacing.)

最佳答案

在 b 情况下将绝对更改为相对

关于html - 为什么我的文字折叠成 4 行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39221997/

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