gpt4 book ai didi

html - 导航,将导航的第二层向左移动几个像素

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

我有这个导航:

http://jsfiddle.net/XDnD9/

它工作正常,但我想将 fdsa 向左移动大约 10 个像素。如果我在其中添加 left: -10px;,它将自身定位在屏幕的左侧。如果我将位置更改为相对位置,那么它会使我的列表崩溃。如何将此子列表定位到左侧 10px?

编辑:正因为我看不清楚,我想移动 fdsa <- 这样

最佳答案

添加以下内容:

ul > li {
display: inline-block;
position: relative;
}

ul > li:hover ul{
display: block;
position: absolute;
left: -10px;
}

position: relative 使嵌套元素的绝对定位相对于该元素进行计算,因此 left: -10px; 不再将内部元素移动到左侧旁边屏幕。

DEMO

关于html - 导航,将导航的第二层向左移动几个像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18162015/

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