Written By:-Avinash Malhotra
Our Website:- Tech Altum
Today we are going to create a CSS DROP MENU
Write following code in body tag
- Create a div with class nav.
- Create a ul inside.
- Create four li inside.
- In second li, create another ul.
- In the new ul, create three li's
<div class="nav">
<ul>
<li><a>Home</a></li>
<li><a>Training</a>
<ul>
<li><a>Web Designing </a></li>
<li><a>Asp.net</a></li>
<li><a>Java</a></li>
</ul>
</li>
<li><a>Carrer</a></li>
<li><a>Contact Us</a></li>
</ul>
</div>
Here is how this will look in browser,
Now Start write CSS.
> is direct chid selector, means direct child of .nav will be called, not grand child.
Here is how this will look in browser,
Now Start write CSS.
> is direct chid selector, means direct child of .nav will be called, not grand child.
- *{ margin:0px; padding:0px}
- .nav{ width:800px; height:200px; background:gray;}
- ul{ list-style:none;}
- .nav > ul{ position:absolute}
- .nav > ul > li{ width:150px; height:50px; background:black; text-align:center; line-height:35px}
- a{ color:white}
- .nav > ul > li:hover{ background:#ccc; color:black}
- .nav > ul > li > ul{ display:none}
- .nav > ul > li:hover > ul{ display:block}
- .nav > ul > li > ul > li{ width:150px; height:50px; background:red; }
No comments:
Post a Comment