两端对齐导航

本文介绍了一个使用HTML和CSS实现的简单网页布局案例,其中包括带有导航链接的页眉及三个主要内容区域。通过CSS样式实现了导航栏的美观展示,并对不同部分进行了定位。

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title></title>
	<style>
		body{
			margin: 0;
			font: 1em "Helvetica";
		}
		ul, li{
			padding: 0;
			margin: 0;
		}
		a{
			text-decoration: none;
		}

		header{
			background-color: #000;
		}
		nav{
			display: table;
			width: 100%;
			max-width: 1024px;
			margin-left: auto;
			margin-right: auto;
		}
		nav ul{
			display: table-row;
		}
		nav li{
			display:  table-cell;
			text-align: center;
		}
		nav li:first-child{
			text-align: left;
		}
		nav li:last-child{
			text-align: right;
		}
		nav a{
			display: block;
			padding: 12px 10px;
			color: #fff;
			text-transform: uppercase;
		}
		nav li:nth-child(even) a{
			color: #83ecc5;
		}

		#section1, #section2, #section3{
			max-width: 1024px;
			height: 1000px;
			padding-top: 0.5em;
			margin-top: 30px;
			margin-left: auto;
			margin-right: auto;
			border: 2px dashed #d5d5d5;
			background-color: #eee;
			text-align: center;
		}
		:target{
			font-size: 30px;
		}
	</style>
</head>
<body>
<header>
	<nav>
		<ul>
			<li><a href="#section1">home</a></li>
			<li><a href="#section2">contact us</a></li>
			<li><a href="#section3">join us</a></li>
			<li><a href="#">our product</a></li>
			<li><a href="#">address</a></li>
			<li><a href="#">help</a></li>
		</ul>
	</nav>
</header>
<section id="section1">section1</section>
<section id="section2">section2</section>
<section id="section3">section3</section>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值