Html Flexbox 代码适用于除 Safari 之外的所有浏览器。为什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35137085/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:53:24  来源:igfitidea点击:

Flexbox code working on all browsers except Safari. Why?

htmlcssflexbox

提问by rafcastro77

Grid columns with list tags, I need to display in correct order per every 3 columns, with auto width enabled for every extra HTML list elements.

带有列表标签的网格列,我需要每 3 列以正确的顺序显示,并为每个额外的 HTML 列表元素启用自动宽度。

This is my example:

这是我的例子:

 <style>
        ul {
            margin: 0;
            padding: 0;
            display: -webkit-flex;
            display: flex;
            -webkit-flex-wrap: wrap;
            -ms-flex-wrap: wrap;
            flex-wrap: wrap;
            -webkit-flex-direction: column;
            -ms-flex-direction: column;
            flex-direction: column;
            height: 150px;
            width:auto;
        }
    
        li {
            float: left;
            display: inline-block;
            list-style: none;
            position: relative;
            height: 50px;
            width: 50px;
        }
    </style>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
    <li>11</li>
    <li>12</li>
    </ul>
这是我到目前为止已经试过,除非我添加此精绝于其他浏览器,但不兼容可与Safari浏览器:display: -webkit-flex;display: -webkit-flex;

I want to convert the output like this:

我想像这样转换输出:

1 4 7 10
2 5 8 11
3 6 9 12

It's important I get this working for Safari browser so far I cant seem to solve this problem at all, I would appropriate any help :)

重要的是我让它在 Safari 浏览器上工作,到目前为止我似乎根本无法解决这个问题,我会提供任何帮助:)

Test link:

测试链接:

http://jsfiddle.net/rafcastro77/3zd7yspg/59/

http://jsfiddle.net/rafcastro77/3zd7yspg/59/

回答by Michael Benjamin

Flexbox is a CSS3 technology. This means it's relatively new and some browsers don't provide full support for flex properties.

Flexbox 是一种 CSS3 技术。这意味着它相对较新,一些浏览器不提供对 flex 属性的完全支持。

Here's a run-down:

这是一个破败:

  • IE 8 and 9 do notsupport flexbox. If you're wanting to use flex properties in these browsers, don't bother wasting your time. A flexbox polyfillmade the rounds for a while, but it didn't work well and is no longer maintained.

  • IE 10 supports a previous version of flexboxand requires vendor prefixes. Be aware that certain properties from the current spec aren't supported in IE10 (such as flex-grow, flex-shrinkand flex-basis). See the Flexbox 2012 Property Index.

  • IE 11 is good, but buggy. It's based on the current flexbox standard. See the KNOWN ISSUEStab on this pagefor some of the problems. Also see: flex property not working in IE

  • With Chrome, Firefox and Edge you're good all around. You'll find minor bugs and inconsistencies but there are usually easy fixes. You'll need to be aware of Implied Minimum Flex Sizing, which sometimes causes sizing and scrollbar problems.

  • Safari versions 9 and up support the current flexbox spec without prefixes. Older Safari versions, however, require -webkit-prefixes. Sometimes min-widthand max-widthcause alignment problems which can be resolved with flexequivalents. See Flex items not stacking properly in Safari

For a complete review of flexbox browser support, see this page: http://caniuse.com/#search=flex

有关 flexbox 浏览器支持的完整评论,请参阅此页面:http://caniuse.com/#search=flex

For a quick way to add many (but not necessarily all) vendor prefixes use Autoprefixer. For Safari, see this articlefor -webkit-prefixes that some prefix generators don't include.

要快速添加许多(但不一定是全部)供应商前缀,请使用Autoprefixer。对于 Safari,请参阅本文-webkit-了解某些前缀生成器不包含的前缀。

For a list of common flex bugs and their workarounds see Flexbugs.

有关常见 flex 错误及其解决方法的列表,请参阅Flexbugs

Also, on this site, there's:

另外,在这个网站上,有:

回答by saravana va

It works for me display: -webkit-inline-box;in safari.

它适用于我显示:-webkit-inline-box; 在野生动物园。