您好我在我的网页上添加了HTML和CSS代码的底部导航栏,但我希望在网站底部集中任何帮助和解决方案非常感谢我附上了HTML,CSS代码和网页的屏幕截图目前我的导航栏位于左侧,非常感谢。
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0;
width: 100%
}
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
margin: 0px auto;
}
.navbar a:hover {
background: #f1f1f1;
color: black;
}
<div class="navbar">
<a href="#">About</a>
<a href="#">Contact</a>
<a href="#">Facebook Page</a>
</div>
HTML导航栏代码
CSS导航栏代码
网页导航栏
答案 0 :(得分:0)
添加到.navbar:
text-align:center;
从.navbar a:
删除float: left;
更新.navbar a:
display: inline-block;
答案 1 :(得分:0)
只需用以下css代码替换您的CSS代码:
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.navbar a {
color: #f2f2f2;
text-align: center;
display: inline-block;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
margin: 0px auto;
}
.navbar a:hover {
background: #f1f1f1;
color: black;
}
以及包含此代码的HTML:
<div class="navbar">
<div class="navbar-inner">
<a href="#">About</a>
<a href="#">Contact</a>
<a href="#">Facebook Page</a>
</div>
</div>
希望此代码能够按预期运行..
答案 2 :(得分:0)
body {margin:0;}
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0;
width: 100%;
}
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background: #f1f1f1;
color: black;
}
.navbar a.active {
background-color: #DDA0DD;
color: white;
}
.main {
padding: 16px;
margin-bottom: 30px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
</style>
</head>
<body>
<div class="navbar">
<a href="#home" class="active">About</a>
<a href="#news">Contact</a>
<a href="#contact">Facebook page</a>
</div>
<div class="main">
<h1>Bottom Navigation Bar</h1>
<p>Some text some text some text.</p>
</div>
</body>
</html>
答案 3 :(得分:-1)
如何在页面底部居中导航栏