简体   繁体   English

响应式CSS:修复了小屏幕中的左侧边栏和页脚冲突

[英]Responsive Css: Fixed Left Sidebar and Footer conflict in small screens

I need your help about this complex problem. 关于这个复杂的问题,我需要您的帮助。

I have fixed header,left Sidebar and absolute sticky footer, and if the content height is smaller than browser's height, no scrolls are visible. 我有固定的页眉,左侧的侧边栏和绝对的粘性页脚,并且如果内容高度小于浏览器的高度,则看不到滚动。

Html HTML

<header></header>
<div class="container">
    <div class="aside-left">
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
        <p>sdfsdfs</p>
    </div>
    <div class="container-mid"></div>
    <div class="push"></div>
    <footer></footer>
</div>

Css CSS

html, body {
    height:100%;
    background:#ffaaaa;
    margin:0;
}
header {
    background: #2f3d4c;
    overflow: hidden;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 600;
    width: 100%;
    height: 75px;
}
.container {
    min-height:100%;
    position:relative;
}
.aside-left {
    background-color: rgba(255, 255, 255, 0.8);
    position: fixed;
    left: 0;
    top: 75px;
    min-height: 100%;
    width: 192px;
    overflow: hidden;
    z-index: 50;
}
.container-mid {
    margin-left: 192px;
    padding-top: 75px;
}
.push, footer {
    height: 55px;
}
footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    color: #ffffff;
    width: 100%;
    background: #2f3d4c;
    z-index: 100;
}
@media only screen and (max-height: 690px) {
    .aside--left {
        position: absolute;
        margin-bottom: -75px;
        float: left;
        margin-right: -100%;
    }
}

Everything is ok in large screens, but when screen height is smaller, and the content of Left Sidebar is higher than container height, footer is overlapping Left Sidebar's content and some part of it is not visible (See the fiddle). 在大屏幕上,一切正常,但是当屏幕高度较小且Left Sidebar的内容高于容器高度时,页脚与Left Sidebar的内容重叠且部分内容不可见(请参见小提琴)。

I need this to work also in IE8+ and keep absolute position for left Sidebar when browser height is small, so that left sidebar will be strached from top to bottom (as I did in media query). 我需要它在IE8 +中也能正常工作,并在浏览器高度较小时保持左侧边栏的绝对位置,以便左侧边栏从上到下被分割(就像我在媒体查询中所做的一样)。 Solution can include JS too, no matter. 解决方案也可以包括JS。

Fiddle : http://jsfiddle.net/frontDev111/dqd2f2dt/1/ 小提琴: http : //jsfiddle.net/frontDev111/dqd2f2dt/1/

If I understood it right you're trying to achieve something like this. 如果我理解正确,那么您正在尝试实现这样的目标。
I fixed the footer with position: fixed and added overflow: auto (to show scrollbars if needed since you hid them) as well as bottom: 55px (footer-height) to your left sidebar. 我用以下position: fixed固定了页脚position: fixed并添加了overflow: auto (在隐藏滚动条时显示滚动条)以及bottom: 55px左侧边栏bottom: 55px (页脚高度)。

http://jsfiddle.net/dqd2f2dt/4/ http://jsfiddle.net/dqd2f2dt/4/

(I filled it with testdata content to test how the content itself does its job) (我在其中填充了testdata内容,以测试内容本身的工作方式)
I tested this with IE9 and it worked properly. 我用IE9进行了测试,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM