css - 为什么显示: flow-root; invalid in mobile

标签 css

我的响应式 css 脚本上有 display: flow-root;。在浏览器响应测试上完美运行,但在我的设备上失败

在我的设备上显示无效当我通过 chrome 中的远程设备检查时,我能够知道这一点。 我可以使用任何替代方案吗??

最佳答案

如果不需要支持IE9或更低版本,可以自由使用flexbox,不需要使用 float 布局。

值得注意的是,如今,随着更好的替代品的使用,越来越不鼓励使用 float 元素进行布局。

  • 显示:内联 block - 更好
  • Flexbox - 最佳(但浏览器支持有限)

Firefox 18、Chrome 21、Opera 12.10 和 Internet Explorer 10、Safari 6.1(包括 Mobile Safari)和 Android 的默认浏览器 4.4 均支持 Flexbox。

有关详细的浏览器列表,请参阅:http://caniuse.com/flexbox .

(也许一旦它的位置完全确立,它可能是绝对推荐的元素布局方式。)


clearfix 是一种元素自动清除其子元素的方法,因此您无需添加额外的标记。它通常用于 float 布局,其中元素 float 以水平堆叠。

clearfix 是一种对抗 zero-height container problem 的方法 用于 float 元素

clearfix 执行如下:

.clearfix:after {
   content: " "; /* Older browser do not support empty content */
   visibility: hidden;
   display: block;
   height: 0;
   clear: both;
}

或者,如果您不需要 IE<8 支持,以下也可以:

.clearfix:after {
  content: "";
  display: table;
  clear: both;
}

通常您需要执行以下操作:

<div>
    <div style="float: left;">Sidebar</div>
    <div style="clear: both;"></div> <!-- Clear the float -->
</div>

使用 clearfix,您只需要以下内容:

<div class="clearfix">
    <div style="float: left;" class="clearfix">Sidebar</div>
    <!-- No Clearing div! -->
</div>

阅读 this article - by Chris Coyer @ CSS-Tricks

关于css - 为什么显示: flow-root; invalid in mobile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48967550/

相关文章:

jquery - 如何制作带有标签的圆形图像?

javascript - 同一页面上两个 fancybox 的不同样式

html - 在 :hover, 上显示隐藏的 div 并使 div 在 CSS/CSS3 鼠标移出后保持可见 5 秒

javascript - 使用 css 或 js 强制调整字体高度

javascript - 将桌面上的悬停导航栏转换为触摸屏上的可点击导航栏

ruby-on-rails - CSS、HTML : How can i make the div or <p> width dynamic as the text line increses/decreses

css - Ext JS 4.2 - 如何创建类似于 KitchenSink 示例中的 header ?

html - 在 bulma 中垂直居中元素

css - 在 <label> 中使用 <div> 是否有效?

css - Zurb Foundation 表单字段的信息帮助文本