Safari上的Flex盒问题 - 移动和桌面

时间:2016-07-20 20:58:37

标签: css mobile safari flexbox mobile-safari

右侧的水平规则与桌面和移动设备上Safari中的文本重叠 如何防止重叠?

Safari on right

http://codepen.io/simply-simpy/pen/EyENLr

h2 {
  align-items: center;
  display: flex;
  font-size: 3.125vw;
  margin-top: 0;
  position: relative;
  width: 100%;
}

h2:after {
  border-top: 1px solid #000;
  content: "";
  display: block;
  margin-left: 1.875vw;
  width: 100%;
}

h2:before {
  border-top: 1px solid #000;
  content: "";
  display: block;
  margin-right: 1.875vw;
  width: 100%;
}

.container {
  align-items: center;
  align-content: center;
  text-align: center;
  display: flex;
  flex-direction: column;
}
<div class="container">
  <h2>precision</h2> 
</div>

1 个答案:

答案 0 :(得分:1)

flex-grow: 1;width: 100%;上使用h2:before代替h2:after即可解决问题。

&#13;
&#13;
h2 {
    align-items: center;
    display: flex;
    font-size: 3.125vw;
    margin-top: 0;
    position: relative;
    width: 100%;
}

h2:after {
    border-top: 1px solid #000;
    content: "";
    display: block;
    margin-left: 1.875vw;
    flex-grow: 1;         /* <--- Replace */
}

h2:before {
    border-top: 1px solid #000;
    content: "";
    display: block;
    margin-right: 1.875vw;
    flex-grow: 1;         /* <--- Replace */
}

.container {
  align-items: center;
  align-content: center;
  text-align: center;
  display: flex;
  flex-direction: column;
}
&#13;
<div class="container">
  <h2>precision</h2> 
</div>
&#13;
&#13;
&#13;