You are on page 1of 4

Learning CSS

Lab 4
Creating navigation bar with dropdown menu

Objective :
1- To create navigation bar and dropdown menu using HTML and CSS.

Example:
Create html file as follow:
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style2.css">
</head>
<body>
<div id="centerd">
<div id="header">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Selling</a>
<ul>
<li><a href="">cloths</a></li>
<li><a href="">accessories</a></li>
<li><a href="">bags</a></li>
</ul></li>
<li><a href="">Contact</a></li>
<li><a href="">About us</a></li>
</ul>

Eng: Samah Al-atifi E-Commerce “B4IT”


</div>
</div>
<div id="left">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Now ,create css file (style2.css) as follow:
div{border-radius: 5px;
padding: 5px;
}
#centerd{
width:900px;
margin:0 auto;
}
#header{
background-color: black;
position:relative;
}
h2{
color: #ffffff;
text-align: center;
}
ul{
list-style-type: none;
margin:0;

Eng: Samah Al-atifi E-Commerce “B4IT”


padding:0;
display: inline;
}
ul li{
width:120px;
display:inline-block;
text-align: center;
}
ul li:hover{
background-color:pink;
}
li a{
color:#ffffff;
font-size: 20px;
text-decoration: none;
padding: 16px 16px;
display: block;
}
ul li ul{display: none;
position: absolute;
}
ul li ul li{
background-color: black;
display: block;
width: 150px;
}
ul li ul li a{display:block;
font-size: 18px;}

Eng: Samah Al-atifi E-Commerce “B4IT”


ul li:hover ul{display: block}
#left{
border:1px solid black;
width:45%;
height: 900px;
float: left;
}
#right{
border:1px solid black;
width:45%;
height: 900px;
float: right;
}
#footer{
height: 60px;
border-radius: 5px;
background-color: black;
clear:both;
}

Eng: Samah Al-atifi E-Commerce “B4IT”

You might also like