私は縦と横のdivをセンタリングしていますが、Safariでは機能しません。Safariのフレックスボックスを使用した縦横のセンタリング
クローム:
サファリ
例を参照:
http://ux-heuristics.webflow.io/私は縦と横のdivをセンタリングしていますが、Safariでは機能しません。Safariのフレックスボックスを使用した縦横のセンタリング
クローム:
サファリ
例を参照:
http://ux-heuristics.webflow.io/私はちょうどあなたのウェブサイトのソースを調べました。マークアップが間違っています。各
<a class="play-btn w-inline-block" href="#"></a>
のリンクを対応する
<div class="visibility-content"></div>
の中に配置する必要があります。
あなたのCSSに
.visibility-content {
position: relative;
}
.visibility-content .play-btn{
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
-o-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
これを追加したより、各セクションのマークアップは次のようになります。
<div class="section-content">
<h2 class="section-title">Visibility of system status</h2>
<p class="section-description">The system should always keep users informed
about what is going on, through appropriate feedback within reasonable time.</p>
<div class="visibility-content">
<a class="play-btn w-inline-block" href="#"></a>
<div class="visibility-content-top"></div>
<div class="visibility-bottom"></div>
</div>
</div>
これがすべてです。
初期の答え:
それはサファリのすべてのバージョンで動作しなければならない場合、あなたはボックスモデルに戻す必要があります:
body { margin: 0;} /* You don't need this rule, it's just for SO snippet */
parent {
min-height: 100vh;
display: block;
position: relative;
}
child {
position: absolute;
display: inline-block;
padding: 3rem;
max-width: 100vw;
max-height: 100vh;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
border: 1px solid red;
overflow-x: hidden;
overflow-y: auto;
}
<parent>
<child>I am centered in all browsers. Yay!</child>
</parent>
<parent>
<child>I am centered in all browsers. Yay!</child>
</parent>
<parent>
<child>I am centered in all browsers. Yay!</child>
</parent>
<parent>
<child>I am centered in all browsers. Yay!</child>
</parent>
<parent>
<child>I am centered in all browsers. Yay!</child>
</parent>
唯一の問題は、<parent>
をmin-height
とする必要があることです。私の個人的な好みは100vh
(ビューポートの高さ)です。
このソリューションは、他の場所に別のdivがあり、そのソリューションがすべてのdivを同じ位置にマージするため、この場合は機能しません。 –
CSSに触れることなく、もっと多くの要素を追加しました。見てみましょう。 –
親Div私はユーザーフレックスボックスが必要です。この機能を削除しても問題ありません。 –
私はSafariが基本的にflexboxに準拠していると思っていました。ちょっと、 '-webkit-'プレフィックスで試してみてください。 – zer00ne
(?)のリンクを投稿したウェブサイトのコードには、これらの要素のフレックスボックスパラメータはありません。また、矢印付きの円を含む 'a'タグは、スクリーンショットが示すコンテナの内部にありません。 – Johannes