gpt4 book ai didi

html - 在绝对定位分区中定位两个 float block

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

这是代码

http://jsfiddle.net/77NBM/12/

两个灰色方 block (“float 1”和“float 2”)必须在与

  • “menu 3”相关的绝对定位分区“submenu_container”中并排放置。

    有人能帮我弄到吗? :(

    谢谢!

  • 最佳答案

    如果您总是有两个元素(“float1 和 float2”),每个元素的宽度为 100px,
    您可以将 .submenu_container 的宽度设置为 220px,它们将彼此并排 float .像这样http://jsfiddle.net/77NBM/13/

    如果元素(“float1 和 float2”)的宽度是动态的,我建议您将 .submenu_container 的宽度设置为动态宽度 javascript 或 jQuery。例如:

    $('#main_menu li').each(function(index) {
    var menuWidth=0;
    $(this).children().children().each(function(index) {
    menuWidth+=$(this).outerWidth();
    }
    $(this).children('.submenu_item').width(menuWidth)
    });

    关于html - 在绝对定位分区中定位两个 float block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7807679/

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