Bootstrap 4如何仅在中等时隐藏div

时间:2017-05-15 21:10:28

标签: bootstrap-4

我想知道如何仅在中等屏幕中隐藏div? 我尝试过很多种组合,但都没有 是否有任何类只能通过添加自定义CSS来隐藏MD?

2 个答案:

答案 0 :(得分:2)

这与解释this question to hide only on small viewport的问题相同。即将推出的Bootstrap 4 Beta更新将隐藏在单个视口(hidden-x)上。

https://github.com/twbs/bootstrap/pull/22113

此更新中将修改所有可见性类。

Bootstrap 4 Beta更新

如果要在Bootstrap 4 Beta中隐藏特定层(断点)上的元素,请相应地使用d-*显示类。请记住,xs是默认(始终隐含)断点,除非被更大的断点覆盖。

  • hidden-xs(仅限)= d-none d-sm-block(与hidden-xs-down相同)
  • hidden-sm(仅限)= d-block d-sm-none d-md-block
  • hidden-md(仅限)= d-block d-md-none d-lg-block
  • hidden-lg(仅限)= d-block d-lg-none d-xl-block
  • hidden-xl(仅限)= d-block d-xl-none

Demo of all hidden / visible classes in Bootstrap 4 beta

另请注意,d-*-block可以替换为d-*-inlined-*-flex等。具体取决于元素的显示类型。有关display classes in beta

的更多信息

答案 1 :(得分:2)

Bootstrap 4 beta dropped the support for hidden-* classes。它被替换为d-classes(显示)。

如果您只想在特定断点及以上显示项目,可以执行以下操作:

<span class="d-none d-xl-inline">
   Here is some text that will only display at extra large displays, 1200px or above.
</span>

另一种方式(更简单):仅在视口小于超大显示器时显示项目:

<span class="d-xl-none">
   Here is some text that will display up until extra large displays, 1200px, but not wider.
</span>

您可以将d-xl-inline的显示类型切换为bootstraps supported d-classes中的任何一种。

另外,这里是related question