今回は grid を使用して文字を上下中央に配置します。
なお、absolute を使用して、文字を上下中央に配置する方法は以下を参考にして下さい。
HTML
わかりやすくする為、文字を表示しているdivタグの背景を赤にしています。
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sample</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div style="background-color: red;">ああああ</div>
</div>
</body>
</html>CSS
display: grid と place-items: center を使うだけで文字を上下左右中央へ配置出来ます。
.container {
display: grid;
place-items: center;
width: 100vw;
height: 100vh;
background-color: #99cc00;
}結果
ああああ
最後に
特にありません。