How do I hide or show content with CSS depending on screen size?(如何根据屏幕大小使用 CSS 隐藏或显示内容?)
问题描述
就像 Bootstrap 一样,Ionic (Ionic 3) 允许我们使用 col-sm-8
、col-md-6
根据屏幕大小调整列的宽度, col-lg-4
.Bootstrap 还附带了诸如 visible-xs
、hidden-sm
等类,使我们能够根据屏幕大小显示或隐藏内容.Ionic 3 是否附带任何可以让我们做同样事情的东西?
Just like Bootstrap, Ionic (Ionic 3) lets us resize the width of a column based on screen size using col-sm-8
, col-md-6
, col-lg-4
. Bootstrap also comes with classes like visible-xs
, hidden-sm
, etc. that enables us to show or hide content according to the screen size. Does Ionic 3 ship with anything that lets us do the same?
推荐答案
我将以下 CSS 类从 Bootstrap 4 Alpha 复制到我的项目中,它们运行良好.
I copied the following CSS classes from Bootstrap 4 Alpha into my project and they work perfectly.
.invisible {
visibility: hidden !important;
}
.hidden-xs-up {
display: none !important;
}
@media (max-width: 575px) {
.hidden-xs-down {
display: none !important;
}
}
@media (min-width: 576px) {
.hidden-sm-up {
display: none !important;
}
}
@media (max-width: 767px) {
.hidden-sm-down {
display: none !important;
}
}
@media (min-width: 768px) {
.hidden-md-up {
display: none !important;
}
}
@media (max-width: 991px) {
.hidden-md-down {
display: none !important;
}
}
@media (min-width: 992px) {
.hidden-lg-up {
display: none !important;
}
}
@media (max-width: 1199px) {
.hidden-lg-down {
display: none !important;
}
}
@media (min-width: 1200px) {
.hidden-xl-up {
display: none !important;
}
}
.hidden-xl-down {
display: none !important;
}
文档
:https://v4-alpha.getbootstrap.com/layout/responsive-utilities/一个>
这篇关于如何根据屏幕大小使用 CSS 隐藏或显示内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何根据屏幕大小使用 CSS 隐藏或显示内容?


- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01