【问题标题】:Fixed sidebar overlaps fixed header固定侧边栏与固定标题重叠
【发布时间】:2013-12-13 12:33:05
【问题描述】:

嗨,我有一个固定位置和 100% 宽度的标题,我还有一个从左侧滑出的侧边栏,它也是固定位置。问题是侧边栏与标题重叠,我希望标题在侧边栏滑出时与侧边栏一起缩小。我认为它会自然而然地做到这一点,因为它被设置为宽度 100%。然而事实并非如此。

有什么想法吗?

谢谢

标题

#header_wrapper{
    width:100%;
    height: 50px;
    /*background-color: #dddddd;*/
    background-color: #2a5f8c;

    border-bottom: 2px solid #ffffff;
    float: left;
    position: fixed;
    z-index: 80;
    border-bottom: 1px solid #444444;

}

侧边栏

#category_wrapper{
    width: 200px;
    height: 100%;
    position: fixed;
    float: left;
    border-right: 3px solid #333;
    display: none;
}

jQuery

$("#header_category").click(function () {           
  $('#category_wrapper').toggle(200);
});

HTML

<div id="category_wrapper"></div><!--end category_wrapper-->        
<div id="header_wrapper"></div><!--end header_wrapper-->

【问题讨论】:

  • 你的 HTML 看起来怎么样?
  • 刚刚在原帖中添加了

标签: javascript jquery html css


【解决方案1】:

而不是将标题的宽度设置为 100%,您可以将 left 属性设置为 0px,将 right 属性设置为 0px,然后当菜单滑出时,您可以将 left 属性设置为左侧菜单的宽度,然后当它返回时将其设置为零。

动画示例:

$( "#category_wrapper" ).animate({
    left: 200,
  }, 200, function() {
    // Animation complete.
  });

【讨论】:

    猜你喜欢
    • 2019-07-27
    • 2015-02-04
    • 1970-01-01
    • 2021-05-29
    • 2019-01-31
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多