我正在创建一个主页,为此,我在视口顶部放置了一个导航栏。导航栏包含一些按钮,请注意,这些按钮应将用户从一个部分导航到另一部分。但实际上它们位于左侧。无论有2、3、4或5个以上的按钮,我都希望它们居中。整个“按钮行”应准确居中。
或在图片中交谈:
完成此任务的常见/可能模式是什么?
我在心中唯一的模式是宽度添加到该按钮home
和ubuntu
最后加margin 0 auto
。
我的navigationbar.css(紫色栏):
#navigationBar {
background-color:#660099;
}
.navigationButton {
background-color:transparent;
border-bottom:2px solid transparent;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:arial;
font-size:17px;
padding:16px 31px;
text-decoration:none;
text-shadow:0px 1px 0px #2f6627;
}
.navigationButton:hover {
background-color:transparent;
border-bottom:2px solid #18ab29;
}
.navigationButton:active {
position:relative;
top:1px;
}
我的home.html:
<!DOCTYPE html>
<html>
<head>
<title>Ubuntu</title>
<link rel="stylesheet" type="text/css" href="style/general.css" />
<link rel="stylesheet" type="text/css" href="style/navigationBar.css" />
</head>
<body>
<div id="navigationBar">
<a href="home.html" class="navigationButton">Home</a>
<a href="ubuntuOverview.html" class="navigationButton">Ubuntu</a>
</div>
</body>
</html>
希望有人能帮忙!
添加此:-
#navigationBar {
background-color:#660099;
text-align:center;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句