gpt4 book ai didi

javascript - HTML/CSS/jQuery- 使内联 block div 完全覆盖其包含的 div,尽管它们的容器被较小的 div 包含

转载 作者:太空宇宙 更新时间:2023-11-04 14:20:22 24 4
gpt4 key购买 nike

我试图让菜单中的一些图标向右溢出,并在用户将菜单句柄向右拖动时显示出来。问题是内联 block div 不想覆盖其容器的整个空间,因为它们的容器轮流包含在一个较小的 div 中(这似乎界定了图标向右移动的距离)。

在图像中,以蓝色突出显示的 div(由 chrome 开发工具)是图标的容器。出于某种原因,线条没有达到其全宽,而是在左侧保持浓缩,由菜单 div 分隔。

我希望这不是很困惑。任何人都可以帮助我吗?如何让图标完全占据其容器的宽度?非常感谢!

Descriptive image 1

Descriptive image 2

代码:

图标的css,由jQuery设置

$("." + localIcons[iconToRender].name).css({
"display": 'inline-block',
"width": box_width,
"height": box_height,
"border-radius": '5px',
"margin": box_margin / 2
});

图标容器:

// appended to the body: <div class="box-menu"> <div class="box-menu-icon-container"> </div> </div>

$( ".box-menu").css({
"position": 'absolute',
//Remember that the width of the menu is set by dragging the jQuery handle, so here I just set a minimum width equal to the size of the handle
"width": box_menu_handle_width,
"min-width": box_menu_handle_width,
"max-width": box_menu_max_width,
"height": box_menu_height,
"left": 0,
"top": '50%',
"margin-top": -( box_menu_height / 2 ),
"background-color": box_menu_color,
"border-radius": '0px 5px 5px 0px',
"overflow": 'hidden'
});

$(".box-menu-icon-container").css({
"height": box_menu_height - 60,
"width": box_menu_max_width
});

最佳答案

您的问题是 box-menu-handlefloat: right 这将图标限制在菜单空间内。 See this example .

换句话说,它的设计不允许图标“渗入”分配给菜单的空间,该空间由控制菜单宽度的句柄定义。

如果您真的想覆盖它,则需要消除 float: right 并将句柄绝对定位在右侧。 See this example .我不知道所有这些将如何与菜单脚本的其他方面交互,但它会允许图标“重叠”它们应该的空间并侵入菜单句柄(这似乎是你想要的,虽然我不知道为什么)。

关于javascript - HTML/CSS/jQuery- 使内联 block div 完全覆盖其包含的 div,尽管它们的容器被较小的 div 包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19986209/

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