當瀏覽器窗口重新調整大小時,此導航欄會重新排列,所有按鈕都從一條水平直線延伸到堆疊在頂部因爲窗戶變得越來越小,所以一個接一個。如何設置它們以保持原位,並很好地粘貼到頁眉徽標的底部,無論窗口大小如何?當瀏覽器窗口重新調整大小時,導航欄按鈕堆疊在彼此的頂部
截圖的問題: http://s29.postimg.org/3tnroxls7/Screenshot1.png
的目標截圖: http://s24.postimg.org/vzuruvqb9/Screenshot2.png
body {
background-color: #FFFFFF;
margin: 0px;
padding: 0px;
text-align: center;
}
header img {
display: block;
margin: 0 auto;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
display: inline-block;
border: 5px solid #0009bc;
}
li {
float: left;
}
a:link, a:visited {
display: block;
width: 139px;
font-weight: bold;
color: #20dbd4;
background-color: #000000;
text-align: center;
padding: 12px;
text-decoration: underline;
text-transform: uppercase;
}
a:hover, a:active {
background-color: #20dbd4;
color: #000000;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex, nofollow, noarchive"/>
<title>Grid Design</title>
</head>
<body>
<header>
<img src="/images/grid-design.jpg" alt="Grid Design" style="width: 987px; height: 243px;"/>
</header>
<nav>
<ul>
<li><a href="#home">home</a></li>
<li><a href="#news">news</a></li>
<li><a href="#about">about</a></li>
<li><a href="#products">products</a></li>
<li><a href="#photos">photos</a></li>
<li><a href="#contact">contact</a></li>
</ul>
</nav>
</body>
</html>
非常好,謝謝。 – NightSpark 2014-10-17 08:45:40