显示:flex和Position:绝对冲突

Vos*_*ers 6 css firefox html5 css3 flexbox

这是 问题的屏幕截图.
到底:1 - Chrome,2 - Opera,3 - Firefox,4 - Edge.

下面我写了可执行代码.
为方便起见,这里有codepen.

基本理念:画廊标签和徽标位于中心位置,其余部分位于侧面.
Transform将用于动画.

除了测量之外,如果您有助于了解如何在Firefox中保持flex,我将不胜感激.
更确切地说,我认为align-items: center在Firefox中没有正确显示.请帮忙.

.gallerypage {
  margin: 0;
  padding: 0;
  background: #fff;
}

.gallerypage .header {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-flow: row nowrap;
      -ms-flex-flow: row nowrap;
          flex-flow: row nowrap;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  width: 100%;
  height: 100px;
  background: gray;
}

.gallerypage .header a {
  cursor: pointer;
  position: absolute;
  -webkit-flex-shrink: 0;
      -ms-flex-negative: 0;
          flex-shrink: 0;
  text-align: center;
  white-space: pre-wrap;
  text-indent: -6px;
  line-height: 30px;
  font-family: "Kaushan Script", cursive;
  font-size: 30px;
}

.gallerypage .header .sketches {
  background-color: #fff;
  width: 110px;
  -webkit-transform: translate(-400px, 0px);
      -ms-transform: translate(-400px, 0px);
          transform: translate(-400px, 0px);
}

.gallerypage .header .smth {
  background-color: #fff;
  width: 140px;
  height: 60px;
  -webkit-transform: translate(-200px, 0px);
      -ms-transform: translate(-200px, 0px);
          transform: translate(-200px, 0px);
}

.gallerypage .header .gallery {
  position: static;
  text-indent: -14px;
  line-height: normal;
  width: 185px;
  height: 90px;
  background: gold;
  font-size: 60px;
}

.gallerypage .header .logo {
  position: static;
  width: 60px;
  height: 80px;
  background: hotpink;
}

.gallerypage .header .logo .vs-logo {
  display: block;
  -webkit-flex-shrink: 0;
      -ms-flex-negative: 0;
          flex-shrink: 0;
  width: 60px;
  height: 80px;
}

.gallerypage .header .blog {
  background-color: #fff;
  width: 60px;
  height: 38px;
  -webkit-transform: translate(200px, 0px);
      -ms-transform: translate(200px, 0px);
          transform: translate(200px, 0px);
}

.gallerypage .header .about {
  white-space: pre-wrap;
  background-color: #fff;
  width: 100px;
  -webkit-transform: translate(400px, 0px);
      -ms-transform: translate(400px, 0px);
          transform: translate(400px, 0px);
}
Run Code Online (Sandbox Code Playgroud)
<div class="gallerypage">
  <div class="header">
    <a class="sketches">Sketches</a>
    <a class="smth">Something serious</a>
    <a class="gallery">Gallery</a><a class="logo"></a>
    <a class="blog">Blog</a><a class="about">About it</a>
  </div>
/<div>
Run Code Online (Sandbox Code Playgroud)

Ali*_*tah 1

垂直和水平对齐问题在 Firefox 中均得到解决。我还应用了一个简单的动画,以确保它与您想要执行的操作兼容(将鼠标悬停在标题上以转换其他项目)。

链接: http: //codepen.io/anon/pen/YNXNLN

要修复 Firefox 上的垂直居中对齐,请添加此样式(我的意思是合并,因为您已经使用了转换属性):

a {
 transform: translateY(-50%);
}
Run Code Online (Sandbox Code Playgroud)

但随后它将位于 Chrome 的最顶部,因此您将添加此样式来修复它:

a {
 top: 50%;
}
Run Code Online (Sandbox Code Playgroud)

水平对齐“左:50%”也会做同样的事情,并且您已经使用了translateX,因此该值将由您决定。