horizontal navigation
HTML
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"
lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>CSS Sprit</title>
<link href="../css/csssprit.css" rel="stylesheet"
type="text/css" media="screen, print" />
</head>
<body>
<div id="nav">
<ul>
<li id="home"><a href="#"><em>home</em></a></li>
<li id="food"><a href="#"><em>food</em></a></li>
<li id="drink"><a href="#"><em>drink</em></a></li>
<li id="info"><a href="#"><em>info</em></a></li>
<li id="contact"><a href="#"><em>contact</em></a></li>
</ul>
</div>
</body>
</html>
@charset "UTF-8";
html, body, div, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, address,
ul, ol, li, dl, dt, dd,
table, th, td, form, fieldset {
margin: 0;
padding: 0;
line-height: 1.0;
font-family:
"Hiragino Kaku Gothic Pro",
"ヒラギノ角ゴ Pro W3",
Meiryo,
"メイリオ",
Osaka,
"MS P Gothic",
"MS Pゴシック",
sans-serif;
}
ul {
list-style-type: none;
}
a {
text-decoration: none;
}
img {
border: 0;
}
em {
visibility: hidden;
}
/* nav */
#nav {
width: 800px;
height: 60px;
margin: 200px auto;
}
#nav li {
float: left;
display: inline;
}
#nav li a {
width: 160px;
height: 60px;
display: block;
background-image: url(../images/csssprit.gif);
background-repeat: no-repeat;
}
/* individual */
#nav li#home a {
background-position: left 0;
}
#nav li#home a:hover, #nav li#home a:active {
background-position: left -80px;
}
#nav li#food a {
background-position: -160px 0;
}
#nav li#food a:hover, #nav li#food a:active {
background-position: -160px -80px;
}
#nav li#drink a {
background-position: -320px 0;
}
#nav li#drink a:hover, #nav li#drink a:active {
background-position: -320px -80px;
}
#nav li#info a {
background-position: -480px 0;
}
#nav li#info a:hover, #nav li#info a:active {
background-position: -480px -80px;
}
#nav li#contact a {
background-position: right 0;
}
#nav li#contact a:hover, #nav li#contact a:active {
background-position: right -80px;
}
Vertical navigation
HTML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"
lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>CSS Sprit</title>
<link href="../css/csssprit2.css" rel="stylesheet"
type="text/css"
media="screen, print" />
</head>
<body>
<div id="nav">
<ul>
<li id="home"><a href="#"><em>home</em></a></li>
<li id="food"><a href="#"><em>food</em></a></li>
<li id="drink"><a href="#"><em>drink</em></a></li>
<li id="info"><a href="#"><em>info</em></a></li>
<li id="contact"><a href="#"><em>contact</em></a></li>
</ul>
</div>
</body>
</html>
@charset "UTF-8";
/* reset */
html,body,div,h1,h2,h3,h4,h5,h6,
p,blockquote,pre,address,
ul,ol,li,dl,dt,dd,
table,th,td,form,fieldset {
margin: 0;
padding: 0;
font-family:
"Hiragino Kaku Gothic Pro",
"ヒラギノ角ゴ Pro W3",
Meiryo,
"メイリオ",
Osaka,
"MS P Gothic",
"MS Pゴシック",
sans-serif;
}
ul {
list-style-type: none;
}
a {
text-decoration: none;
}
img {
border: 0;
}
em {
visibility: hidden;
}
/* nav */
#nav {
width: 200px;
height: 250px;
margin: 100px auto;
}
#nav li a{
width: 200px;
height: 50px;
display: block;
background-image: url(../images/csssprit.jpg);
background-repeat: no-repeat;
}
/* individual */
#nav li#home a {
background-position: 0 0;
}
#nav li#home a:hover, #nav li home a:active {
background-position: -220px 0;
}
#nav li#food a {
background-position: 0 -50px;
}
#nav li#food a:hover, #nav li food a:active {
background-position: -220px -50px;
}
#nav li#drink a {
background-position: 0 -100px;
}
#nav li#drink a:hover, #nav li drink a:active {
background-position: -220px -100px;
}
#nav li#info a {
background-position: 0 -150px;
}
#nav li#info a:hover, #nav li info a:active {
background-position: -220px -150px;
}
#nav li#contact a {
background-position: 0 -200px;
}
#nav li#contact a:hover, #nav li contact a:active {
background-position: -220px -200px;
}