{"action":"opened","issue":{"url":"https://api.github.com/repos/BenFeiJr/something-of-css/issues/1","repository_url":"https://api.github.com/repos/BenFeiJr/something-of-css","labels_url":"https://api.github.com/repos/BenFeiJr/something-of-css/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/BenFeiJr/something-of-css/issues/1/comments","events_url":"https://api.github.com/repos/BenFeiJr/something-of-css/issues/1/events","html_url":"https://github.com/BenFeiJr/something-of-css/issues/1","id":152191789,"number":1,"title":"IE这回在css flex中扳回一局？","user":{"login":"BenFeiJr","id":18638015,"avatar_url":"https://avatars.githubusercontent.com/u/18638015?v=3","gravatar_id":"","url":"https://api.github.com/users/BenFeiJr","html_url":"https://github.com/BenFeiJr","followers_url":"https://api.github.com/users/BenFeiJr/followers","following_url":"https://api.github.com/users/BenFeiJr/following{/other_user}","gists_url":"https://api.github.com/users/BenFeiJr/gists{/gist_id}","starred_url":"https://api.github.com/users/BenFeiJr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenFeiJr/subscriptions","organizations_url":"https://api.github.com/users/BenFeiJr/orgs","repos_url":"https://api.github.com/users/BenFeiJr/repos","events_url":"https://api.github.com/users/BenFeiJr/events{/privacy}","received_events_url":"https://api.github.com/users/BenFeiJr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-01T10:01:32Z","updated_at":"2016-05-01T10:01:32Z","closed_at":null,"body":"哇哇哇，开年头一篇文章呀，为了镇得住场面，特意起了这么个标题。没错，就是标题党。\r\n\r\n事情还得从上周五开始说起，那天下午，我正在公司改产品妹子提的需求，改了一会后，就切换到Chrome看看效果，走走单元测试，呵呵呵。但是我突然就发现一个问题呀，这个flex item显示的不对呀，而且在FF和Chrome都显示“不对”，倒是在IE11里显示“正常”。\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18638015/14940902/71b801e0-0fbb-11e6-86fa-cbe2e0900330.png)\r\n\r\n正常的话就是上面这个图所显示的，html和css代码如下图：\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18638015/14940910/a8c7c92c-0fbb-11e6-8b52-d4930a1626ca.png)\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18638015/14940912/c5e18476-0fbb-11e6-8dd5-72ca6ffbd89c.png)\r\n\r\n但是现在却显示成这个鬼样子了，↓↓↓\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18638015/14940921/58730d96-0fbc-11e6-9d2b-c38de8de3fbe.png)\r\n\r\n看到这个，我脑子里第一蹦出来的是第二个select框option里内容太多了。可是我的三个filter-item的flex值都是1呀，对应起来可是flex: 1 1 0，标准的三等分呀。当时时间比较赶，我就给select写了个max-width属性，临时算看着没毛病。\r\n\r\n可是周末在家，想想，这也不是个事呀，我可是通读过flex规范的呀，怎么能容忍这种不受我控制的样式出现呢。于是，我又通读了一遍规范，呵呵呵，脸好疼。\r\n\r\n突然，脑子里蹦出来，之前在Firefox里出现过这种情况，当时在stackoverflow搜到的解决方法时加个min-width: 1px; 还说这个是Firefox的bug，可是这个情况现现在在Chrome和FF里都出现了，那它现在是不是bug就存疑了，随后拿关键字搜了一下，呵呵呵。\r\n\r\n![_20160501171300](https://cloud.githubusercontent.com/assets/18638015/14941124/90157066-0fc3-11e6-9f13-180bc9b66276.png)\r\n\r\n[链接在这：](http://stackoverflow.com/questions/27424831/firefox-flexbox-overflow)\r\n\r\n然后又顺着找到了这里：\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18638015/14941127/a5eb769c-0fc3-11e6-8a91-6f699a86dfd8.png)\r\n\r\n[链接在这：](https://www.fxsitecompat.com/en-CA/versions/34/)\r\n\r\n呵呵呵，FF和Chrome的flex item的min-width的initial value现在是auto了，贴一段官方的描述：\r\n\r\n> To provide a more reasonable default minimum size for flex items, this specification introduces a new auto value as the initial value of the min-width and min-height properties defined in CSS 2.1.On a flex item whose overflow is visible in the main axis, when specified on the flex item’s main-axis min-size property, the following table gives the minimum size...\r\n\r\n上面一段blabla，意思就是说，flex item如果它的overflow属性值是visible的话，那么现在min-width和min-height的initial value是auto啦，至于这个auto最后是怎么计算的，它是根据specified size、transferred size、content size三者由一些规则算出来的，有兴趣可以找找官方文档自己看看，在我写的页面里呢，最后计算胜出的是content size，再贴一段官方描述：\r\n\r\n> The content size is the min-content size in the main axis, clamped, if it has an aspect ratio, by any definite min and max cross size properties converted through the aspect ratio, and then further clamped by the max main size property if that is definite\r\n\r\n所以在我这里确实是第二个select的某个option的text太长了，所以并不是什么bug，呵呵呵。\r\n\r\n解决办法，就是把flex-item的visible属性设为非visible的合法值，或者手动设置一下min-width或者min-height的值为非auto的其他合法值。\r\n"}}