Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Drop Down Menu using CSS
WhatsApp
Ankur Soni
5y
22.8
k
0
0
25
Blog
Introduction
A drop-down menu is a graphical control element.It is similar to a list box, which collects multiple values and allows the user to choose one value from a list. When a drop-down list is inactive, it displays a single value. A drop-down menu is very easy to create with the help of some advanced selectors a drop-down menu can be easily created with CSS.
Program code
The HTML Structure:
<
%@ Page
Language
=
"C#"
AutoEventWireup
=
"true"
CodeBehind
=
"Drop.aspx.cs"
Inherits
=
"drop.Drop"
%
>
<!DOCTYPE html
>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
link
href
=
"pop.css"
rel
=
"stylesheet"
/>
<
title
>
</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
class
=
"drop"
>
<
ul
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Home
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
About us
</
a
>
<
ul
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Contect
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Features
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
About Campus
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Demo
</
a
>
</
li
>
</
ul
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Contect
</
a
>
<
ul
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Director
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Principal
</
a
>
</
li
>
<
li
>
<
a
href
=
"
[email protected]
"
>
Management
</
a
>
</
li
>
</
ul
>
</
li
>
</
ul
>
</
div
>
</
form
>
</
body
>
</
html
>
The CSS Styling
.drop ul ul {
display
:
none
;
}
.drop ul li:hover ul {
display
:
block
;
}
.drop ul li {
float
:
left
;
}
.drop ul li a {
color
:
#ffffff
;
display
:
block
;
padding
:
10px
10px
;
position
:
relative
;
text-decoration
:
none
;
}
.drop ul ul li {
float
:
none
;
position
:
relative
;
border-top
:
1px
solid
#000000
;
border-bottom
:
1px
solid
#000000
;
}
.drop ul li {
position
:
relative
;
}
.drop ul ul {
top:
38px
;
position
:
absolute
;
background
:
#000000
;
border-radius:
0px
;
padding
:
0
;
}
.drop ul {
list-style
:
none
;
position
:
relative
;
display
:
inline-table
;
background
:
#000000
;
padding
:
0 20px
;
border-radius:
10px
;
}
.drop ul ul li a {
padding
:
10px
10px
;
color
:
#fff
;
width
:
100px
;
text-align
:
center
;
}
.drop ul ul li a:hover {
background
:
#cfc5c5
;
color
:
#000000
;
}
.drop ul li:hover {
background
:
#cfc5c5
;
color
:
#000000
;
}
.drop ul li a:hover {
color
:
#000000
;
}
Output
Drop Down Menu using CSS
Up Next
Highlight HTML Table Alternate Row Colors Using CSS Selector
Ebook Download
View all
Frontend Developer Interview Questions and Answers
Read by 940 people
Download Now!
Learn
View all
Membership not found