css white-space:nowrap horizontal scroll bug

心已入冬 提交于 2019-12-19 02:54:08

问题


I have the following markup

<style type="text/css">
    #outer
    {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        width:100%;
        white-space:nowrap;
    }

    #inner
    {
        background-color:#CCCCCC;
        margin:0px 4px 0px 4px;
        padding:5px 5px 0px 5px;
        border:1px solid #9A9A9A;
        border-width:1px 1px 0px 1px;
    }

</style>

<div id="outer">
    <div id="inner">
    TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
    </div>
</div>

When the browser is wide enough, it looks like this

When the browse is resized narrow, it looks like this

I want the gray background of the narrow view to extend all the way to the right when I scroll. What about my markup and css is causing this unwanted effect (occurs in Chrome, FF3 and IE8)


回答1:


An easy solution is to do this: on #outer, remove width: 100% and add float: left.

Live Demo



来源:https://stackoverflow.com/questions/4964041/css-white-spacenowrap-horizontal-scroll-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!