css - Bootstrap 在较小的屏幕上附加了侧边栏问题

标签 css twitter-bootstrap

我在较小的屏幕上禁用 .affix 类时遇到问题。我试过在这里找到的答案:How can I disable Bootstrap's "affix" on smaller screens?没有运气。

我正在尝试添加两个侧边栏,一左一右,然后在较小的屏幕上不添加它们。这是我的 CSS:

#accordian2.affix {
left: 10;
position: fixed;
width:15%;

#notes.affix {
right: 0;
position: fixed;
width:16%;
margin-right: 45px;

}

我试过这个来禁用较小的屏幕:

@media (min-width: 768px) {
  .affix {
      position: static;
  }
}

运气不好。我应用到我的 HTML 的唯一其他类是 .accordian 用于左侧的那个,没有其他类用于右侧的。

如果您需要查看 HTML,请告诉我。

谢谢!

最佳答案

试试这个:

@media all and (max-width: 768px) {
  #accordian2.affix, #notes.affix {
      position: static;
  }
}

看起来您只是遗漏了一些东西(全部和),而且您使用的是最小值而不是最大值。 Min 意味着宽度必须至少为 768px 才能应用规则。

关于css - Bootstrap 在较小的屏幕上附加了侧边栏问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26855387/

相关文章:

html - 将一个 div 放在其他所有内容之上的特定位置,这样它就不会移动任何其他内容?

javascript - 一个一个地为一组元素设置阴影动画

javascript - Bootstrap 推/拉 - Div 未正确对齐

jquery - 如何让 Superfish 菜单水平宽度 100%?

html - 容器内的 Carousell Controller

twitter-bootstrap - 当将值作为参数传递给 addin 时将值传递给 ember.js 组件(例如 ember-bootstrap-modals-manager)

css - 使用 JavaFX 8 和 css 加载自定义字体

jquery - 在 bootstrap 幻灯片中抓取 Twitter 提要

html - Bootstrap 3 实现导致所有元素的大右移

javascript - 工具提示无法与任何不使用 :active state 的元素正常工作