【问题标题】:Fullscreen website with horizontal overflow scroll on 100% width全屏网站在 100% 宽度上具有水平溢出滚动
【发布时间】:2013-01-24 21:14:45
【问题描述】:

我的代码有一个问题,我找不到解决方案。 我有左侧边栏 w: 300px h:100% ,我希望右侧 div (内容区域)为 w: 100% 和 h:100% 水平滚动条..

但是我的代码有问题,我无法弄清楚,右边的 div 越过了侧栏,如果我放 margin-left:300px,那么它们 300px 会添加到 100px 的权重上。

希望你能理解我,这是我的代码:

HTML:

<div id="wrapper">
   <?php include '../side_bar.php' ?>

    <div id="content">
       <div id="scroll">
        <img src="../images/design1.jpg" width="759" height="565"> 
        <img src="../images/design1.jpg" width="759" height="565"> 
        <img src="../images/design1.jpg" width="759" height="565"> 
       </div>
    </div>
</div>

CSS:

body, html {
    margin: 0;
    padding: 0;
    height:100%;
    width:100%;
}

#wrapper {
    width:100%;
    height:100%;
    display:inline-block;
}

#side_bar {
    float:left;
    width:300px;
    height:100%;
    position:fixed;
    border-right:#000 solid 1px;
}

#content {
    float:left;
    height:100%;
    width:100%;
    position:fixed;
}

#scroll {
    height:100%;
    width:100%;
    display:inline-block;
    position:absolute;
    overflow-x:scroll;
    overflow-y:hidden;  
    white-space: nowrap; 
}

【问题讨论】:

    标签: width fullscreen horizontal-scrolling css


    【解决方案1】:

    我能够通过以下调整后的 CSS 获得您想要的功能:

    body, html {
    margin: 0;
    padding: 0;
    height:100%;
    width:100%;
    }
    #wrapper {
    width:100%;
    height:100%;
    display:inline-block;
    }
    
    #side_bar {
    /*float:left;*/
    top:0;
    left:0;
    width:300px;
    height:100%;
    position:fixed;
    border-right:#000 solid 1px;
    background-color:#333;
    }
    
    #content {
    /*float:left;*/
    top:0;
    left:0;
    height:100%;
    width:100%;
    position:fixed;
    }
    
    #scroll {
    height:100%;
    /*width:100%;*/
    right:0px;
    left:301px; /*Because of border */
    display:inline-block;
    position:absolute;
    overflow-x:scroll;
    overflow-y:hidden;  
    white-space:nowrap;
    }
    

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      您可以使用 jQuery 的 fullPage.js 插件轻松创建全屏网站:

      它不仅提供了一种创建垂直部分的方法,还提供了水平部分。

      一些优点:

      • 移动鼠标滚轮自动滚动
      • 在 URL 中使用锚点 (#)
      • 兼容触控设备
      • 兼容旧浏览器(> IE7)
      • 提供回调和许多有用的函数
      • 在不同设备中经过严格测试

      【讨论】:

        猜你喜欢
        • 2022-01-17
        • 2014-01-25
        • 2014-05-10
        • 1970-01-01
        • 2012-04-05
        • 2011-05-16
        • 2012-06-13
        • 1970-01-01
        • 2013-07-08
        相关资源
        最近更新 更多