gpt4 book ai didi

html - Webkit-flex 工作而 moz-flex 不工作

转载 作者:行者123 更新时间:2023-11-28 07:05:15 25 4
gpt4 key购买 nike

所以我在网页上有这个 CSS,当我在 chrome 中测试它时,webkit-box-flex 完全按照它的意思去做。

但是,在 firefox 上,它没有。

有人可以看看我的 CSS 并告诉我我需要更改哪些内容才能使其在两者上都能正常工作吗?

.buttonGroup
{
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack:justify;
-webkit-box-flex: 1;
box-sizing: border-box;
display: -moz-box;
-moz-box-orient: horizontal;
-moz-box-pack:justify;
box-sizing: border-box;

}

.buttonGroup > li
{
display: block;
-webkit-box-flex: 1;
-moz-box-flex: 1;
box-flex: 1;


border: solid 1px #9a9a99;
border-left: none;
border-radius: 0px;
-webkit-border-radius: 0px;
text-align: center;

background: rgb(243,243,243); /* Old browsers */
background: -moz-linear-gradient(top, rgba(243,243,243,1) 0%, rgba(194,194,194,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(243,243,243,1)), color-stop(100%,rgba(194,194,194,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(243,243,243,1) 0%,rgba(194,194,194,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(243,243,243,1) 0%,rgba(194,194,194,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(243,243,243,1) 0%,rgba(194,194,194,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(243,243,243,1) 0%,rgba(194,194,194,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f3f3f3', endColorstr='#c2c2c2',GradientType=0 ); /* IE6-9 */

color: #6b6b6b;
font-size: 16px;
padding: 10px;
}

http://jsfiddle.net/z6pc7wvt/

我看过-moz-box-flex is not flexing? Works with (Chrome/Webkit)

但他的修复对我来说没有意义。

最佳答案

看来您正在使用旧的前缀和语法。 Firefox 现在原生支持无前缀的 flexbox。

当前的语法是:

.buttonGroup {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
box-sizing: border-box;
}
.buttonGroup > li {
-webkit-box-flex:1;
-webkit-flex:1;
-ms-flex:1;
flex:1;
}

$("ul.buttonGroup").click(function (event) {
$("li", this)
.removeClass("selected")
.filter(event.target)
.addClass("selected");
});
.buttonGroup {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
box-sizing: border-box;
}
.buttonGroup > li {
-webkit-box-flex:1;
-webkit-flex:1;
-ms-flex:1;
flex:1;

border: solid 1px #9a9a99;
border-left: none;
border-radius: 0px;
-webkit-border-radius: 0px;
text-align: center;
background: rgb(243, 243, 243);
/* Old browsers */
background: -moz-linear-gradient(top, rgba(243, 243, 243, 1) 0%, rgba(194, 194, 194, 1) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(243, 243, 243, 1)), color-stop(100%, rgba(194, 194, 194, 1)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(243, 243, 243, 1) 0%, rgba(194, 194, 194, 1) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(243, 243, 243, 1) 0%, rgba(194, 194, 194, 1) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(243, 243, 243, 1) 0%, rgba(194, 194, 194, 1) 100%);
/* IE10+ */
background: linear-gradient(to bottom, rgba(243, 243, 243, 1) 0%, rgba(194, 194, 194, 1) 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3f3f3', endColorstr='#c2c2c2', GradientType=0);
/* IE6-9 */
color: #6b6b6b;
font-size: 16px;
padding: 10px;
}
.buttonGroup > li:first-child {
border-left: solid 1px #9a9a99;
-webkit-border-top-left-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.buttonGroup > li:last-child {
-webkit-border-top-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.buttonGroup > li.selected {
background: rgb(25, 58, 127);
/* Old browsers */
background: -moz-linear-gradient(top, rgba(25, 58, 127, 1) 0%, rgba(43, 86, 178, 1) 5%, rgba(97, 150, 241, 1) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(25, 58, 127, 1)), color-stop(5%, rgba(43, 86, 178, 1)), color-stop(100%, rgba(97, 150, 241, 1)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(25, 58, 127, 1) 0%, rgba(43, 86, 178, 1) 5%, rgba(97, 150, 241, 1) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(25, 58, 127, 1) 0%, rgba(43, 86, 178, 1) 5%, rgba(97, 150, 241, 1) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(25, 58, 127, 1) 0%, rgba(43, 86, 178, 1) 5%, rgba(97, 150, 241, 1) 100%);
/* IE10+ */
background: linear-gradient(to bottom, rgba(25, 58, 127, 1) 0%, rgba(43, 86, 178, 1) 5%, rgba(97, 150, 241, 1) 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#193a7f', endColorstr='#6196f1', GradientType=0);
/* IE6-9 */
color: #fff;
border-color: #193a7f;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="buttonGroup">
<li class="selected">One</li>
<li>Two</li>
<li>Three</li>
</ul>

JSfiddle Demo

您可能想开始使用像 Autoprefixer 这样的前缀工具或 Prefix Free .他们承担了所有艰苦的工作。

关于html - Webkit-flex 工作而 moz-flex 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32994477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com