6

我正在寻找任何像modernizr(实际上没有)为“旧浏览器”(polyfill)启用flexbox的javascript库。

是的,我知道这是一个非常新的功能(事实上“没有”是一个有效的答案),但我希望有这样的东西,我总是很难水平+垂直居中,这真的会有所帮助并缩短工作。

我的意思是这个 flexbox:http ://weblog.bocoup.com/dive-into-flexbox/ (最新的)

4

2 回答 2

4

这可能为时过早。WebKit 最近才实现它,根本没有任何移动 WebKit 支持的迹象,Opera刚刚发布了对它的支持,而 Gecko 的实现仍处于 alpha 阶段。IE?哈。

但据我所知,不,新的 flexbox 没有 polyfill。 Flexie支持旧的 flexbox,并且有一张可以支持新的语法……也许你可以帮他们一把?

我想你总是可以使用旧的 flexbox,但是你已经过时了。糟糕的情况。

于 2013-01-18T00:00:37.963 回答
1

你将不得不创建自己的。 http://www.sitepoint.com/detect-css3-property-browser-support/有一个标题为“滚动你自己的检测代码”的部分

基本上你需要这样的东西:

// detect CSS display:flex support in JavaScript
var detector = document.createElement("detect");
detector.style.display = "flex";
if (detector.style.display === "flex") {
    console.log("Flex is supported");
}
else
{
    console.log("Flex is not supported");
}

要对此进行扩展并创建一个函数:

function DetectDisplayValue(val)
{
  // detect CSS display:val support in JavaScript
  // 
  var detector = document.createElement("detect");
  detector.style.display = val;
  if (detector.style.display === val) {
    console.log("Display value: " + val + " is supported");
  }
  else
  {
      console.log("Display value: " + val + " is not supported");
  }
}
于 2013-01-17T23:16:02.470 回答