gpt4 book ai didi

html - 如何让绝对元素在其父元素中 float ?

转载 作者:太空宇宙 更新时间:2023-11-04 10:26:06 25 4
gpt4 key购买 nike

因此,我正在尝试让下拉列表作为菜单的一部分工作。我有一个 ul,左边添加了几个 li 元素,然后我想让一个 li 元素 float 到右边。我以前是使用相对位置来做这个的,但现在我希望它能够溢出并显示在它下面的任何东西上。

我发现了这个问题: CSS: Overflow Auto and Z-index并发现您必须使用绝对位置才能使这种溢出发生。那么,我该怎么做呢?

这是基本的代码结构:

<ul>
<li id="right_item1"/> (relatively positioned)
...
<li id="absolute_position"/> (absolutely positioned, floating right)
</ul>

最佳答案

这应该适合你。

ul{
position:relative; // You need this
}

#absolute_position{
position:absolute;
right:0;
bottom:0;

}

关于html - 如何让绝对元素在其父元素中 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36780782/

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