我在每個按鈕周圍放置一個div,並將它們設置爲內聯。他們只是想堆疊,因爲我一直試圖把它們集中起來。如何垂直居中按鈕?
這是我的HTML:
body{
\t background-color:black;
}
#light{
\t margin-left:50%;
\t margin-right:70%;
}
#dark{
\t margin-left:50%;
\t margin-right:50%;
\t display:inline-block;
}
\t
h3{
\t color:white;
\t font-family:Courier New;
\t font-size:24px;
\t margin-left:500px;
}
<!DOCTYPE html>
<html>
<head>
<title>question reality.</title>
<link rel="stylesheet" type="text/css" href="intro page.css">
</head>
<body>
<h3>make your choice.</h3>
<div id="light"><button>Light</button></div>
<div id="dark"><button>Dark</button></div>
</body>
</html>
這是什麼這個東西是做擷取畫面:
使用文本對齊:中心財產代替保證金的左,右,並給予嘗試 –
請參考此鏈接:https://stackoverflow.com/questions/396145/how-to-vertically-center-a-div-for-all-browsers。它有一個更好的方式來處理這個問題。 – Sujith
可能重複[如何垂直居中所有瀏覽器的div?](https://stackoverflow.com/questions/396145/how-to-vertically-center-a-div-for-all-browsers) – NewUser