CSS问题…位置固定消失

问题描述 投票:1回答:2

[当我缩小浏览器并水平滚动时,left_nav消失了。我试图改变立场。但这没有用。有什么建议吗?

#left_nav {
    position: fixed;
    height: 95%;
    width: 100px;
    background-color: #ededed;
    border-right: 1px solid #aaa
}

#container {
    margin-left: 100px;
    position: absolute;
    overflow: auto;
    width: 75%;
    min-width: 1129px;
    overflow: hidden;
    min-width: 1100;
    background-color: #fff;
    border-right: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    border-left: 1px solid #aaa;
    -webkit-border-bottom-right-radius: 20px;
    -moz-border-radius-bottomright: 20px;
    border-bottom-right-radius: 20px
}
css css-position
2个回答
1
投票
#left_nav {
position: fixed;
top:0;
left:0;
height: 95%;
width: 100px;
background-color: #ededed;
border-right: 1px solid #aaa
}

您应如上所述为固定元素指定左侧和顶部。这将在浏览器窗口的顶部和左侧放置左侧导航0px。

您是否要相对于容器指定它?如果是这样,则需要将left_nav的位置设置为absolute,并将容器的位置设置为relative


0
投票

尝试将min-width: 100px;添加到您的left_nav,并摆脱容器上的min-width: 1100; ...

注意,您正在复制min-width属性;这是一个禁忌:

min-width: 1129px; 
overflow: hidden; 
min-width: 1100;
© www.soinside.com 2019 - 2024. All rights reserved.