Professional Documents
Culture Documents
Chapter 4
Navigation bar, dropdown and image gallery
CSS
Navigation Bar
Navigation bar
• Having easy-to-use navigation is important for any web
site.
• Example
li a {
display: block;
width: 60px;
}
Vertical Navigation bar
Example explained:
• display: block; - Displaying the links as block elements
makes the whole link area clickable (not just the text),
and it allows us to specify the width (and padding,
margin, height, etc. if you want)
• width: 60px; - Block elements tsake up the full width
available by default. We want to specify a 60 pixels
width
Vertical Navigation bar
Example
You can also set the width of ul {
<ul>, and remove the width of list-style-type: none;
<a>, as they will take up the margin: 0;
full width available when padding: 0;
displayed as block elements. width: 60px;
This will produce the same }
result as our previous
example: li a {
display: block;
}
Vertical Navigation bar Example
ul {
Create a basic vertical list-style-type: none;
margin: 0;
navigation bar with a gray padding: 0;
width: 200px;
background color and change background-color: #f1f1f1;
li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
one:
Horizontal
Navigation Bar
Horizontal Navigation Bar
There are two ways to create a horizontal navigation bar. Using
inline or floating list items.
li { li {
display: inline; float: left;
} }
Horizontal Navigation Bar
Example explained:
•float: left; - Use float to get block elements to
float next to each other
•display: block; - Allows us to specify padding
(and height, width, margins, etc. if you want)
•padding: 8px; - Specify some padding
between each <a> element, to make them look
good
•background-color: #dddddd; - Add a gray
background-color to each <a> element
Horizontal Navigation Bar
Border Dividers
Fixed Navigation Bar