css - 调整大小时不显示响应式侧边栏图像

标签 css twitter-bootstrap

这是我的侧边栏:https://jsfiddle.net/8ejwykwv/1/

问题是在小屏幕上,边栏完全消失了。而我想要实现的是在一定的屏幕尺寸上,只显示图像。示例:没有主页文本的主页图标。在非常小的屏幕上,只有一个按钮可以左右或自上而下滑动侧边栏。

我试过用

 @media(min-width:42em){
     .sidebar{
        width:4em;
     }
 }

但我几乎迷路了。 我了解媒体查询以及可以用它们做什么,但我不确定如何使用我的侧边栏和顶部栏进行操作,以便我拥有喜欢的 fa-fa 栏,点击时将显示的不仅仅是图像。

链接作为我一直在尝试的引用:

This link和/或 This example

感谢任何帮助。我是初学者,所以如果这可能很简单,我会提前道歉。感谢您的帮助!

最佳答案

只需在侧边栏类中固定宽度:

.sidebar {
    position: fixed;
    top: 50px;
    bottom: 0;
    width:160px !important;
    left: 0;
    z-index: 1000;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;  
    border-right: 1px solid #eee;
    background-color: black

}

这是 fiddle https://jsfiddle.net/c8h5ede7/8/

编辑 您也可以试试这个解决方案

 @media only screen and (max-width: 42em) {
    .sidebar{
        width:8em !important;
     }
}

https://jsfiddle.net/c8h5ede7/12/

关于css - 调整大小时不显示响应式侧边栏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47341441/

相关文章:

html - CSS3 不透明度动画 + 显示 :none

css - SCSS中嵌套元素+元素选择器

html - 在响应式网页中对齐 div 时出错

jquery - 在 bootstrap 下拉列表中选择新元素不会清除之前的选择

javascript - 如何添加菜单以在 Bootstrap 中切换导航栏

html - 在 CSS 中渐进式显示导航

html - 如何垂直对齐字体超棒的输入复选框及其标签?

css - Bootstrap : Add a button link in the bottom right corner of a thumbnail

button - 一键多个弹出窗口

javascript - 自定义 JQuery 显示 : Uncaught ReferenceError: $ is not defined on modal