html - 为移动尺寸的屏幕移除 css 中的 flex

标签 html css flexbox

我正在使用 flexbox/flex 来居中内容。但是我想在小于 768px 的屏幕上删除 flex 属性

CSS

.row-eq-height {
min-height: 400px;
display: flex;
}

.row-eq-height .col-md-6, 
.row-eq-height .col-md-12 {
flex: 1;
display: flex;
align-items: center;
}

.section-content {
position: relative;
flex: 1;
text-align: center;
}

@media screen and (max-width: 768px) {

...

我不确定是什么 css 取消了 flex 以便我可以不同地定位我的元素

最佳答案

@media screen and (max-width: 768px) {} 中编写的每个类都将覆盖之前的类。

.row-eq-height {
   min-height: 400px;
   display: flex;
 }

 @media screen and (max-width: 768px) {
  .row-eq-height {
    /*display property will be overriden as any class further inside this scope*/
    display: block;
  }

正如之前的回答所述,display:initialdisplay:inherit 因为任何 display 属性都会取消 display:flex.

关于html - 为移动尺寸的屏幕移除 css 中的 flex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40480144/

相关文章:

javascript - Toggle Javascript 中的 Onclick 问题

javascript - 如何根据单击哪个单选按钮显示不同的文本框?

javascript - 第二次尝试单击输入字段时自动对焦不起作用

html - 为什么我的背景图片不显示

html - Flexbox 容器内联占用剩余宽度

html - 使用 CSS 在进度条上显示进度条的值(数字),例如 55%

java - DWR: dwr 未定义

html - 居中和右对齐带有文本溢出的 flexbox 元素,并在左侧留出空白

javascript - 使用 Javascript 更改 CSS 动画可见性

html - 如何制作 flex 元素 block 元素?