如何在safari中制作柔性盒?

ako*_*ito 34 html css safari flexbox

如何在Safari中使柔性盒工作?我有一个响应式导航,使用CSS弹性框来响应,由于某种原因,它将无法在Safari中工作.

这是我的代码:

#menu {
	clear: both;
	height: auto;
	font-family: Arial, Tahoma, Verdana;
	font-size: 1em;
	/*padding:10px;*/
	margin: 5px;
	display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
	display: -moz-box;    /* OLD - Firefox 19- (buggy but mostly works) */
	display: -ms-flexbox;  /* TWEENER - IE 10 */
	display: -webkit-flex; /* NEW - Chrome */
	display: flex;         /* NEW, Spec - Opera 12.1, Firefox 20+ */
	justify-content: center;
	-webkit-box-align: center;
	-webkit-flex-align: center;
	-ms-flex-align: center;
	-webkit-align-items: center;
	align-items: center;fffff
	font-style: normal;
	font-weight: 400px;
}
#menu a:link {
	display: inline-block;
	width: 100px;
	height: 50px;
	padding: 5px;
	background-color: yellow;
	/*border: 1px solid #cccccc;*/
	margin: 5px;
	display: flex;
	flex-grow: 1;
	align-items: center;
	text-align: center;
	justify-content: center;
	font-weight: bold;
	color: #1689D6;
	font-size: 85%;
}
#menu a:visited {
	display: inline-block;
	width: 100px;
	height: 50px;
	padding: 5px;
	background-color: yellow;
	/*border: 1px solid #cccccc;*/
	margin: 5px;
	display: flex;
	flex-grow: 1;
	align-items: center;
	text-align: center;
	justify-content: center;
	font-weight: bold;
	color: #1689D6;
	font-size: 85%;
}
#menu a:hover {
	display: inline-block;
	color: #fff;
	width: 100px;
	height: 50px;
	padding: 5px;
	background-color: red;
	/*border: 1px solid #cccccc;*/
	margin: 5px;
	display: flex;
	flex-grow: 1;
	align-items: center;
	text-align: center;
	justify-content: center;
	font-weight: bold;
	font-size: 85%;
}
#menu a:active {
	display: inline-block;
	color: #fff;
	width: 100px;
	height: 50px;
	padding-top: 5px;
	padding-right: 5px;
	padding-left: 5px;
	padding-bottom: 5px;
	background-color: red;
	/*border: 1px solid #cccccc;*/
	margin: 5px;
	display: flex;
	flex-grow: 1;
	align-items: center;
	text-align: center;
	justify-content: center;
	font-style: normal;
	font-weight: bold;
	font-size: 85%;
}
Run Code Online (Sandbox Code Playgroud)
<nav id="menu">
  <a href="#">Philadelphia</a>
  <!--<a href="#">Vacation Packages</a>-->
  <a href="#">United States of America</a>
  <a href="#">Philippines</a>
  <a href="#">Long Destinations Names</a>
  <a href="#">Some Destination</a>
  <a href="#">Australia</a>
</nav>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/cyberjo50/n55xh/3/

是否有一个前缀我缺少使其在Safari中工作?

hus*_*n39 41

给 flex 一个值解决了我的问题,例如

flex: 1 0 auto
Run Code Online (Sandbox Code Playgroud)

  • 2020 年 3 月为我工作。 (6认同)
  • 在我的例子中,“flex: 0;”为“div”提供了 0 高度。我将其替换为“flex: 0 0 auto”并且它起作用了。我记得这是一个已知的错误,但我在网上没有找到任何参考 (2认同)

tsl*_*ter 20

我不得不为safari添加webkit前缀(但是flex不是flexbox):

display:-webkit-flex

  • OP*已经*`display:-webkit-flex`,我不知道这是如何回答这个问题的. (30认同)

小智 6

试试这个:

select {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -ms-flexbox;
}
Run Code Online (Sandbox Code Playgroud)


小智 6

只是这个

display: -webkit-box;   /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox;  /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
display: flex;         /* NEW, Spec - Firefox, Chrome, Opera */
Run Code Online (Sandbox Code Playgroud)

这对我有用