html+css制作一级水平导航条

<!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>
        body{
            padding: 0px;
            margin: 0px;
        }
        #daohang{
            position:absolute;/*绝对布局*/
            top: 40px;
            left: 300px;
            padding-top: 0px;
            width: 900px;
            height: 60px;
            background-color: rgb(100, 171, 237);
        }
        ul{/*设置导航栏的框框*/
		 	margin: auto;/*框框整体的位置,auto控制的是左右距离为自动调节*/
			width: 600px;/*框框的长度*/
			height: 35px;/*框框的宽度*/
		}
		li{
			list-style-type: none;/* 去掉li前的点 */
			float: left;/*将li设置成做浮动,变为联动*/
		}
		a{
			display: block;/*将超链接变成块状*/
			width: 100px;/*设置块的长度*/
			height: 60px;/*设置块的宽度*/
			line-height: 60px;/*设置字体在块中的高度*/
			color: #fff;/*设置字体颜色*/
			text-align: center;/*字体居中*/
			text-decoration: none;/*去掉下划线*/
			font-size: 15px;/*设置字体大小*/
		}
		a:hover{
			background-color: blue;
		}


    </style>
</head>
<body>
        <div id="daohang">
                    <ul>
                            <li><a href="">导航1</a></li>
                            <li><a href="">导航2</a></li>
                            <li><a href="">导航3</a></li>
                            <li><a href="">导航4</a></li>
                            <li><a href="">导航5</a></li>
                            <li><a href="">导航6</a></li>
                        </ul>
        </div>

    </div>
</body>
</html>

实现效果:
在这里插入图片描述

  • 8
    点赞
  • 67
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值