我是靠谱客的博主 独特花瓣,这篇文章主要介绍css怎么把导航栏固定住,现在分享给大家,希望可以做个参考。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

css怎么把导航栏固定住

可以给导航栏添加固定定位是导航来固定住。语法为“position:fixed;”。

示例如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style type="text/css"> *{margin:0;padding: 0;} ul{ list-style-type: none; overflow: hidden; background-image:url(1118.02.png); position: fixed; top: 0; width: 100%; } li { float: left; } li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover{ background-color: red; } </style> </head> <body> <ul> <li><a href="#home">首页</a></li> <li><a href="#news">新闻动态</a></li> <li><a href="#contact">联系我们</a></li> <li><a href="#about">关于我们</a></li> </ul> <div style="background-color:pink;height:1500px;"></div> </body> </html>
登录后复制

输出结果:

+2.gif

(学习视频分享:css视频教程)

以上就是css怎么把导航栏固定住的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是独特花瓣最近收集整理的关于css怎么把导航栏固定住的全部内容,更多相关css怎么把导航栏固定住内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(193)

评论列表共有 0 条评论

立即
投稿
返回
顶部