html中的底部导航栏,html中导航栏固定在头部或者底部

demo

.body{

width: 98%;

height: 200%;

}

.nav{

background: url("global_nav_bg.png") repeat-x scroll 0 0 transparent;

height: 35px;

width: 100%;

z-index: 9998;

position: fixed;

left: 0px;

}

.top{

top: 0px;

}

.bottom{

bottom: 0px;

}

.nav ul{

display: inline;

float: left;

font-size: 14px;

margin: 0 0 0 163px;

}

.nav ul li{

list-style: none outside none;

padding: 0 0 0 2px;

display: inline;

float: left;

position: relative;

z-index: 9998;

color: #FFFFFF;

display: inline-block;

height: 16px;

line-height: 16px;

padding: 9px 10px 8px;

}

ul li a:active, ul li a:link, ul li a:visited{

color: #FFFFFF;

text-decoration: none;

}

ul li a:hover{

color: #FF0000;

text-decoration: underline;

}

需要用到的图片global_nav_bg.png

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当创建一个固定导航时,你可以使用 HTML 和 CSS 来实现。下面是一个简单的示例: HTML: ```html <!DOCTYPE html> <html> <head> <title>固定导航</title> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <header> <nav> <ul> <li><a href="#">首页</a></li> <li><a href="#">关于</a></li> <li><a href="#">服务</a></li> <li><a href="#">联系我们</a></li> </ul> </nav> </header> <main> <!-- 页面内容 --> </main> <footer> <!-- 底部内容 --> </footer> </body> </html> ``` CSS (styles.css): ```css body { margin: 0; padding: 0; } header { position: fixed; top: 0; left: 0; width: 100%; background-color: #333; padding: 20px; } nav ul { list-style-type: none; margin: 0; padding: 0; } nav ul li { display: inline-block; margin-right: 10px; } nav ul li a { color: #fff; text-decoration: none; } main { margin-top: 80px; /* 确保页面内容不被导航遮挡 */ } footer { background-color: #333; color: #fff; padding: 20px; } ``` 在上面的示例,我们创建了一个固定导航。通过将 `<header>` 元素的 `position` 属性设置为 `fixed`,它将固定在页面的顶部。导航在 `<nav>` 元素,使用无序列表 `<ul>` 和列表项 `<li>` 来创建导航链接。在 CSS ,我们设置了导航的背景颜色、内边距等样式,并使用 `position: fixed` 将其固定在页面顶部。 在 `<main>` 元素,我们使用 `margin-top` 属性来确保页面内容不被导航遮挡。 希望这个示例对你有所帮助!如果你有任何问题,请随时问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值