2017-02-27 8 views
-3

これは私がhtmlで縦列に並んだテキストを作る方法は?

<body background="2017-02-27 (5).png"> 
    <table cellspacing="1" style="width: 100%; height: 100%"> 
     <tr> 
      <td valign="middle" align="center"> 
      <h1>Click here to Get Game and See Yourself</h1> 
      </td> 
     </tr> 
    </table> 

</body> 

今何をしたかであるあなたは、ここで

http://romancepriorities.com/test/

テキストが上に結果を見ることができます。テキストを画面の中央に表示します。それで私は何が間違っていたのですか?

enter image description here ページ全体が1つの大きな背景を持つ1つの大きなファイルであり、中央に大きなテキストが必要です。

動作しません。ゲームを手に入れるにはここをクリックしてください。それは水平に整列していますが、まだ上にあります。

+0

...何に対して? – Quentin

+0

あなたのコードに何が間違っているのかを調べようとしましたが、すべての試みはすでにテーブルのテキストを垂直に整列させていました... – AymDev

+0

ページ全体が垂直に整列しています。ごめんなさい。私はコードを変更する –

答えて

-3

position:absoluteを使用できます。トップ:50%;高さなし:100%

<table cellspacing="1" style="position: absolute; top: 50%; width: 100%;"> 
    <tr> 
     <td valign="middle" align="center"> 
     <h1>Click here to Get Game and See Yourself</h1> 
     </td> 
    </tr> 
</table> 
0

1)高さ "行高さ:150px;"あなたのdivの高さは、あなたがそれを中心に揃えるために同じでなければなりません。

2) "line-height:100vh;"テキストがページの中央に表示されます。垂直方向に整列

h1{ 
 
    text-align: center; 
 
    line-height: 150px;  /* 1) The height same as your div height where you want to centre it. 2) line-height: 100vh will make it to centre of the page. */ 
 
}
<table cellspacing="1" style="width: 100%; height: 100%"> 
 
    <tr> 
 
     <td valign="middle" align="center"> 
 
     <h1>Click here to Get Game and See Yourself</h1> 
 
     </td> 
 
    </tr> 
 
</table>

関連する問題