CSSでボタン要素を垂直方向と水平方向の中央に配置するにはどうすればよいですか?
例
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.centered {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
border: 3px solid rgb(0, 70, 128);
}
button{
font-size: 18px;
border: none;
padding:10px;
background-color: darkblue;
color:white;
}
</style>
</head>
<body>
<h1>Centering Example</h1>
<div class="centered">
<button>This button is centered</button>
</div>
</body>
</html> 出力
上記のコードは次の出力を生成します-
-
CSSで要素を垂直方向と水平方向に中央揃えする方法は?
CSSを使用して要素を垂直方向および水平方向に中央揃えするには、コードは次のとおりです- 例 <!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .centered { display: flex; &n
-
CSSを使用してWebサイトを水平方向に中央揃えする方法は?
CSSを使用してWebサイトを水平方向に中央揃えにするためのコードは、次のとおりです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { background: rgb(255, 238, 0); fon