在中心Bootstrap 3网格旁边创建固定侧边栏

 itlzk 发布于 2023-02-11 10:12

我想创建一个固定的侧边栏,它存在我的中心Bootstrap网格之外.我在尝试这样做时面临的挑战是确定应用/覆盖我的其他样式,.container以便在调整屏幕大小时它不会与我的侧边栏重叠.

对于初学者来说我只使用了CSS框架的栅格部,因此.container,.row.col-md-12从拉代码bootstrap.css文件本身并不是定制.另外请记住我正在使用Bootstrap 3,所以请不要为以前的线程中经常被问到的Bootstrap 2的流体网格解决方案提出建议.

HTML

Lorem ipsum dolor sit amet, nunc dictum at.

CSS

html, body {
  height: 100%;
  width: 100%;
}
#left-nav {
  background: #2b2b2b;
  position: absolute;
  top: 0px;
  left: 0px;
  height: 100%;
  width: 250px;
}

eggy.. 111

正如drew_w所说,你可以在这里找到一个很好的例子.

HTML


CSS

#wrapper {
  padding-left: 250px;
  transition: all 0.4s ease 0s;
}

#sidebar-wrapper {
  margin-left: -250px;
  left: 250px;
  width: 250px;
  background: #CCC;
  position: fixed;
  height: 100%;
  overflow-y: auto;
  z-index: 1000;
  transition: all 0.4s ease 0s;
}

#page-content-wrapper {
  width: 100%;
}

.sidebar-nav {
  position: absolute;
  top: 0;
  width: 250px;
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width:767px) {

    #wrapper {
      padding-left: 0;
    }

    #sidebar-wrapper {
      left: 0;
    }

    #wrapper.active {
      position: relative;
      left: 250px;
    }

    #wrapper.active #sidebar-wrapper {
      left: 250px;
      width: 250px;
      transition: all 0.4s ease 0s;
    }

}

JSFIDDLE

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有