画面の途中でテーブルをCSS?
に垂直に揃える方法画面の途中でテーブルをCSS?
に垂直に揃える方法How can I vertically align a table in the middle of the screen with css?
</div一般的にこれの行に沿ったものは、定義された高さを持つブロック要素ではかなりよく機能します。
<事前> <コード> table { position: absolute; top: 50%; margin-top: -50%; }は、身長がないので、ページを中心に困難ですが、これは機能していると思います。
<事前> <コード> html { height: 100%; }それに応じて行動するブラウザの違いがあるかもしれません。
Generally something along the lines of this works pretty well in any block element with a defined height.
table { position: absolute; top: 50%; margin-top: -50%; }
Centering on the page is harder since you don't have a defined height, but I think this works.
html { height: 100%; }
You may encounter some browser differences, act accordingly.
</divは、垂直方向の整列がテーブルセルの作業をしているため、単に言ったばかりです。
<コード> body, html { height: 100%; } body { display: table; } #wrapper { display: table-cell; vertical-align: middle; height: 80%; }
これは垂直方向にあなたのPageWrapperを真ん中に合わせて80%
にします。Shortly said, just make your body a table, because vertical-align does work on table-cells:
body, html { height: 100%; } body { display: table; } #wrapper { display: table-cell; vertical-align: middle; height: 80%; }
This will vertical align your pagewrapper to middle and let it be fluid 80%
</div表に固定された高さを与えることができ、次にこのサイト i 'からCSSを無料で適応させることができます。行ったばかりです。
説明を複雑にしていますが、基本的にあなたはあなたのコンテンツの周囲の画面の50%の高さで1ピクセルの高「地平線」を設定してから、中心にある要素の上部をその50%ずつずらします。身長。編集:これは、最初に私の解決策をしました。説明&amp;すべて。
If you can give the table a fixed height, then feel free to adapt the CSS from this site I've just done.
Bit complicated to explain, but basically you set a 1 pixel high 'horizon' at 50% height of the screen around your content, then offset the top of the element to be centred (i.e. your table) by 50% of its height.
EDIT: Here's the article I originally made my solution from, with explanation & everything.
</div© 2022 cndgn.com All Rights Reserved. Q&Aハウス 全著作権所有