【发布时间】:2017-07-04 12:23:23
【问题描述】:
我在每个按钮周围放置了一个 div,并将它们都设置为内联。他们只是想堆叠,因为我一直试图让他们居中。
这是我的 HTML:
body{
background-color:black;
}
#light{
margin-left:50%;
margin-right:70%;
}
#dark{
margin-left:50%;
margin-right:50%;
display:inline-block;
}
h3{
color:white;
font-family:Courier New;
font-size:24px;
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>
这是这个东西在做什么的屏幕截图:
【问题讨论】:
-
用 text-align:center 属性代替左右边距试试
-
请参考此链接:stackoverflow.com/questions/396145/…。它有更好的处理方法。
-
我不认为在文件名中有空格是一个好习惯,就像你为你的 css 文件所做的那样:
href="intro page.css"