Today, I have been involved in ps and fixed a navigation bar on the top. The layout is given below. The position: fixed is used.
[Html] <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Link rel = "stylesheet" type = "text/css" href = "css/in.css"/>
</Head>
<Body>
<Div id = "head">
<Div id = "header">
<Div class = "nav">
<Ul>
<Li> <a> Home page </a> </li>
<Li> <a> download </a> </li>
<Li> <a> lexicon </a> </li>
<Li> <a> others </a> </li>
<Li> <a> help </a> </li>
<Li> <a> official forum </a> </li>
</Ul>
</Div>
</Div>
</Div>
<Div id = "main">
A <br/>
B <br/>
C <br/>
D <br/>
E <br/>
123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/>
</Div>
</Body>
</Html>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Link rel = "stylesheet" type = "text/css" href = "css/in.css"/>
</Head>
<Body>
<Div id = "head">
<Div id = "header">
<Div class = "nav">
<Ul>
<Li> <a> Home page </a> </li>
<Li> <a> download </a> </li>
<Li> <a> lexicon </a> </li>
<Li> <a> others </a> </li>
<Li> <a> help </a> </li>
<Li> <a> official forum </a> </li>
</Ul>
</Div>
</Div>
</Div>
<Div id = "main">
A <br/>
B <br/>
C <br/>
D <br/>
E <br/>
123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/> 123456789 <br/>
</Div>
</Body>
</Html>
Css code
[Css] @ charset "UTF-8 ";
/* CSS Document */
*{
Margin: 0px;
Padding: 0px;
Font-size: 14px;
}
Body {
Background-color: # ECECEC;
}
# Head {
Position: fixed;
Top: 0px;
Background: # FAFAFA;
Width: 100%;
Height: 54px;
Border-bottom: 1px solid # E8E8E8;
Box-shadow: 0 1px 5px rgba (34, 25, 25, 0.2 );
Z-index: 100;
}
# Header {
Margin: 0 auto;
Width: 960px;
Height: 54px;
}
. Nav {
Float: left;
Height: 54px;
Width: auto;
}
. Nav ul,. nav li {
Float: left;
List-style: none outside none;
}
Li {
Padding: 0 15px;
Color: #585858;
Display: block;
Line-height: 54px;
Border-right: 1px solid # E8E8E8;
}
# Main {
Position: relative;
Top: 66px;
Margin: 0 auto;
Padding: 10px;
Width: 960px;
Background: none repeat scroll 0 0 # FFFFFF;
Border: 1px solid # C7C7C7;
}
@ Charset "UTF-8 ";
/* CSS Document */
*{
Margin: 0px;
Padding: 0px;
Font-size: 14px;
}
Body {
Background-color: # ECECEC;
}
# Head {
Position: fixed;
Top: 0px;
Background: # FAFAFA;
Width: 100%;
Height: 54px;
Border-bottom: 1px solid # E8E8E8;
Box-shadow: 0 1px 5px rgba (34, 25, 25, 0.2 );
Z-index: 100;
}
# Header {
Margin: 0 auto;
Width: 960px;
Height: 54px;
}
. Nav {
Float: left;
Height: 54px;
Width: auto;
}
. Nav ul,. nav li {
Float: left;
List-style: none outside none;
}
Li {
Padding: 0 15px;
Color: #585858;
Display: block;
Line-height: 54px;
Border-right: 1px solid # E8E8E8;
}
# Main {
Position: relative;
Top: 66px;
Margin: 0 auto;
Padding: 10px;
Width: 960px;
Background: none repeat scroll 0 0 # FFFFFF;
Border: 1px solid # C7C7C7;
}