【问题标题】:How did he get the sidebar to remain on the left, even as the right side of the page can scroll?即使页面的右侧可以滚动,他是如何让侧边栏保持在左侧的?
【发布时间】:2014-01-24 03:11:21
【问题描述】:

我正在尝试了解 960 网格,并且正在研究 Skeleton。

http://www.getskeleton.com

如果您访问该页面,您会注意到当页面的右侧上下滚动时,左侧是固定的(侧边栏)始终保持在原位。如果你缩小浏览器窗口经过一个点,侧边栏就会消失。

我查看了 css,但找不到有关此侧边栏如何工作的任何信息。他是怎么做到的?

【问题讨论】:

    标签: html css skeleton-css-boilerplate


    【解决方案1】:

    侧边栏使用position:fixed; 保持原位。响应端(重新调整浏览器的大小)很可能是使用媒体查询。示例:

    @media only screen and (max-width: 999px){
       //if screen is less than or equal to 999px (just a random number) execute this code
    }
    
    @media only screen and (min-width: 1000px){
       //if screen is greater than or equal to 1000px (just a random number) execute this code
    }
    

    更新

    RESIZE THE BROWSER

    【讨论】:

    • 我理解右边 - 我不明白他是如何让侧边栏消失的。
    • 简单,使用媒体查询。假设当屏幕较小时侧边栏位于某个容器中,例如 1000 像素,只需将该容器设置为 display:none。我会用一个例子来更新我的答案。
    猜你喜欢
    • 2023-02-13
    • 2012-02-04
    • 2016-08-11
    • 2018-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    相关资源
    最近更新 更多