twitter-bootstrap Bootstrap 4“隐藏”类不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48123445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap 4 "hidden" class doesn't work
提问by hayden
I'm using Bootstrap v4 with it's default CSS and JS. I'm trying to apply the classes hidden, hidden-XX-downand hidden-XX-upto various divs, buttons, etc. But it doesn't seem to affect anything. All other classes work, except this one.
我使用 Bootstrap v4 和它的默认 CSS 和 JS。我试图应用类hidden,hidden-XX-down以及hidden-XX-up各种申报单,按钮等,但它似乎并没有造成任何影响。除了这个类之外,所有其他类都可以工作。
Here's an example:
下面是一个例子:
<div class="row">
<div class="col col-10 offset-1 hidden-sm-down">
<p class="text-primary text-center">Lorem ipsum dolor sit amet.</p>
</div>
</div>
I want the paragraph to be invisible when I resize the window to a smaller width (sm-down), yet it remains visible and nothing happens.
当我将窗口调整为较小的宽度(sm-down)时,我希望该段落不可见,但它仍然可见并且没有任何反应。
回答by hayden
Use d-none, d-sm-none, d-md-noneetc.
使用d-none,d-sm-none,d-md-none等。
https://getbootstrap.com/docs/4.0/utilities/display/
https://getbootstrap.com/docs/4.0/utilities/display/
To only display for md up (hide for sm down) use:
只显示 md up (hide for sm down) 使用:
<div class="d-none d-md-block"></div>
回答by hayden
Well, using the displayproperty definitely solved the problem.
好吧,使用该display属性确实解决了问题。
In case anyone wonders why the hiddenclasses didn't work, it's very simple... They no longer exist in version 4 of Bootstrap. That's what you get from watching old tutorial videos.
如果有人想知道为什么这些hidden类不起作用,这很简单……它们不再存在于 Bootstrap 的第 4 版中。这就是您从观看旧教程视频中获得的信息。
回答by Chatoxz
If you already have code with the hidden class I recommend creating one:
如果您已经有隐藏类的代码,我建议您创建一个:
.hidden{
display: none;
}
Cheers
干杯
回答by Kelly
In Bootstrap 4, the class invisible took the place of the class hidden.
在 Bootstrap 4 中,类 invisible 代替了 hidden 类。

