background css 100%宽度水平滚动问题

时间:2013-07-10 08:06:07

标签: css width footer background-color horizontal-scrolling

Please See the issue

当我将窗口滚动到水平然后页脚和标题断开时,我正面临这个问题。

请帮助CSS

您可以在http://yeszindagi.com/

查看现场演示
    body {
        font-family: Arial, Helvetica, sans-serif;
        font-size:1.3em;
        min-height:100%;
    }


    .containerMain {
        min-height:100%;    
        width: 100%;
    }


    .full {
    width:100%;
    }

    .fixed {
    width:900px;    
    }


    .footer {
        border-top:1px dashed #000;
        margin-top:5px;
        height:50px;
        background-color:#F7B200;
        bottom:0px;
        position:relative;
    }

---------------------------- HTML CODE ----------------- -----------------------

    <div class="containerMain">
    ....
    .....
    .........
    <div class="full footer clear ">
        <div class="fixed center">
            <div class="left">
                <ul class="links">
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Contact</a></li>
                    <li><a href="#">Contact</a></li>
                </ul>
            </div>    
            <div class="social right">
                <a href="#" target="_blank" title="Facebook"><span class="facebook-mini"></span></a>
                <a href="#" target="_blank"><span class="twitter-mini" title="Twitter"></span></a>
                <a href="#" target="_blank"><span class="pinterest-mini" title="Youtube"></span></a>
                <a href="#" target="_blank"><span class="linkedin-mini" title="Linkedin"></span></a>
            </div>
        </div>
    </div>
    </div>

4 个答案:

答案 0 :(得分:10)

解决此问题的最佳方法是通过CSS。

min-width应用于其父容器,并确保其子容器具有width: 100%。见下文:

.containerMain {
    width: 100%;
    min-width: 900px;
}
.footer {
    width: 100%;
}

答案 1 :(得分:2)

我建议你用jquery解决一个问题:

$(window).bind('resize', resizeHandler);

function resizeHandler(){
var newWidth = $(document).width();

$('.footerWrapper').css('width', newWidth);

}

放入您想要适合文档宽度的函数div并添加到body onload =“resizeHandler()”属性。

答案 2 :(得分:0)

CSS属性下面应该可以解决这个问题。

.divwithbackground{ overflow-x: hidden;}

答案 3 :(得分:-1)

仅通过css无法实现。你需要进行jquery集成。

$('.footer').css({width:$('html').outerWidth()+$(window).scrollLeft()});

试试这个。应该工作!

相关问题