Position of drop down menu using only CSS and HTML - html

Is it possible to position drop down menu under specific button, and not first one by default using only css?
For example, how to but drop down under forth button instead of first one (under INFO instead HOSTEL button)? I know that people usually use <ul> and <li> elements when creating drop downs, but I am interested is it possible to choose a position when using <button> element.
.dropbtn {
background-color: #000000;
color: white;
padding: 8px;
font-size: 9px;
width: 80px;
margin-right: 5px;
font-family: 'Istok Web', sans-serif;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
float: left;
top: 6.7%;
margin-left: 5px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #95e5c4;
font-family: 'Istok Web', sans-serif;
text-align: center !important;
font-size: 9px;
width: 80px;
box-shadow: 0px 6px 12px 0px rgba(0,0,0,0.2);
z-index: ;
}
.dropdown-content a {
color: black;
padding: 8px 12px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #e6e6e6}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="dropdown">
<button class="dropbtn">HOSTEL</button>
<button class="dropbtn">RESERVATION</button>
<button class="dropbtn">GALLERY</button>
<button class="dropbtn">INFO</button>
<div class="dropdown-content">
EVENTS IN ZG
</div>
<button class="dropbtn">FIND US</button>
</div>

Adding margin-left to the dropdown-content class can be a good choice but may not be the best one. And obviously you have to calculate the value of margin which fits for your actual case. In the example you provided, setting
margin-left to 267px looks fine, I guess.
Edit:
As, OP stated that screen resolutions can be an issue, here's the pure css solution without using any extra margin.
.dropbtn {
background-color: #000000;
color: white;
padding: 8px;
font-size: 9px;
width: 80px;
margin-right: 5px;
font-family: 'Istok Web', sans-serif;
border: none;
cursor: pointer;
}
.dropdown {
display: inline-block;
float: left;
top: 6.7%;
margin-left: 5px;
}
.dropdown-content {
display: none;
background-color: #95e5c4;
font-family: 'Istok Web', sans-serif;
text-align: center !important;
font-size: 9px;
width: 80px;
box-shadow: 0px 6px 12px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content-parent {
display: inline-block;
position: relative;
}
.dropdown-content a {
color: black;
padding: 8px 12px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #e6e6e6
}
.dropdown:hover .dropdown-content {
display: block;
position: absolute;
}
<div class="dropdown">
<button class="dropbtn">HOSTEL</button>
<button class="dropbtn">RESERVATION</button>
<button class="dropbtn">GALLERY</button>
<div class="dropdown-content-parent">
<button class="dropbtn">INFO</button>
<div class="dropdown-content">
EVENTS IN ZG
</div>
</div>
<button class="dropbtn">FIND US</button>
</div>

you can use bootstrap's navbar for it like this:
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Page 1-1</li>
<li>Page 1-2</li>
<li>Page 1-3</li>
</ul>
</li>
<li>Page 2</li>
<li>Page 3</li>
</ul>
</div>
</nav>
<div class="container">
<h3>Navbar With Dropdown</h3>
<p>This example adds a dropdown menu for the "Page 1" button in the navigation bar.</p>
</div>
see it on full screen: https://jsfiddle.net/gmy1Lwfj/

Related

How to change current page link colours?

so I've tried a few different things out. But ultimately no success. I'm trying to change the colour of the "Home" link to stay a different colour than the rest when we are specifically on the homepage. So for example, say I'm on the homepage, I specifically want that colour to be orange for the home link, and then when I click on About link, about link changes to orange and the home goes to default white
Html:
<!--Header-->
<header class="header-main">
<!--Navigation menu-->
<nav class="navigation">
<!--Bakingwithwill Logo-->
<img class="logo" src="imgs/bww.png" alt="Bakingwithwill" />
<!--Navigation links-->
<div class="nav-links">
<!--Unordered list of navigation items-->
<ul class="nav-menu">
<li id="active-home" class="nav-items">Home</li>
<li class="nav-items">About</li>
<li class="nav-items">Order</li>
<li class="nav-items">Contact</li>
<li class="nav-items">Cart</li>
</ul>
</div>
<div class="footer-nav">
<!--Footer portion of the side navbar-->
<div class="nav-social">
<!--Navigation of Bakingwithwill social media accounts-->
<ul class="nav-social-list">
<li class="social-icons">
<i class="fab fa-facebook"></i>
</li>
<li class="social-icons">
<i class="fab fa-instagram"></i>
</li>
</ul>
</div>
<p class="copyright">Copyright Bakingwithwill</p>
<!--Copyright-->
</div>
</nav>
<img class="header-banner" src="imgs/bww-home-banner.jpg" alt="Bakingwithwill bread banner"/>
<!--Main image-->
<div class="main">
<!--Contents outside the side navbar representing header page-->
<h2 class="baking-heading">Bakingwithwill</h2>
<h1 class="welcome-heading">Welcome!</h1>
<h2 class="intro-heading">Get a slice of the best bread in<br>
Chatham-Kent!</h2>
</div>
</header>
CSS:
/*Base styles*/
body {
font-family: 'Oswald', sans-serif;
}
h1 {
font-family: 'Satisfy', cursive;
}
/*Home styles*/
header {
width: 100%;
height: 585px;
}
/*Side bar navigation menu*/
.navigation {
height: 100%;
width:160px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #3D3732;
overflow-x: hidden;
padding-top: 20px;
opacity: 90%;
}
.navigation a {
text-decoration: none;
}
.logo {
border-radius: 50%;
height: 70px;
width: 70px;
margin-top: 10px;
margin-left: 45px;
}
#active-home:link, #active-home:visited {
color:#E88F2A !important;
}
.navigation li, p {
text-decoration: none;
color: #FFFFFF;
display: block;
text-align: center;
}
.navigation .nav-items {
padding-right: 30px;
padding-top: 10px;
text-align: center;
}
.navigation .social-icons {
list-style-type: none;
text-align: center;
display: inline;
font-size: 15px;
padding: 5px;
margin-top: 50px;
color: #FFFFFF;
margin-left: 15px;
text-decoration: none;
}
.navigation li:hover {
color: #E88F2A;
}
.navigation p {
font-size: 10px;
text-align: center;
padding: 6px 8px 6px 16px;
}
.main {
margin-left: 160px;
padding: 0px 10px;
}
.footer-nav {
margin-top: 200px;
}
/*Social media icons*/
.navigation i {
text-decoration: none;
color: #FFFFFF;
}
.navigation i:hover {
color: #E88F2A;
}
/*Text overlaying the image*/
.baking-heading {
color: #E88F2A;
font-family: 'Satisfy', cursive;
position: relative;
margin-top: 40px;
padding-left: 50px;
font-size: 50px;
}
.welcome-heading, .intro-heading {
font-family: 'Oswald', sans-serif;
position: relative;
}
.welcome-heading, .baking-heading {
transform: rotate(-13deg);
}
.welcome-heading {
padding-left: 130px;
font-size: 50px;
color: #FFFFFF;
}
.intro-heading {
padding-top: 200px;
font-size: 50px;
text-align: center;
color: #FFFFFF;
}
.header-banner {
/*Image styles*/
margin-top: -40px;
position: absolute;
width: 100%;
height: 585px;
}
So for example, say I'm on the homepage, I specifically want that
colour to be orange for the home link, and then when I click on About
link, about link changes to orange and the home goes to default white
One CSS-only approach is to:
add a class to the <body> element of each page
add classes to each of your links (or to the list-items containing the links)
Home Page:
<body class="home-page">
<ul class="nav-menu">
<li class="nav-items home">Home</li>
<li class="nav-items about">About</li>
<li class="nav-items order">Order</li>
<li class="nav-items contact">Contact</li>
<li class="nav-items cart">Cart</li>
</ul>
About Page:
<body class="about-page">
<ul class="nav-menu">
<li class="nav-items home">Home</li>
<li class="nav-items about">About</li>
<li class="nav-items order">Order</li>
<li class="nav-items contact">Contact</li>
<li class="nav-items cart">Cart</li>
</ul>
Then you can change the color of the relevant link on each page:
.nav-items a {
color: white;
}
.home-page .nav-items.home a,
.about-page .nav-items.about a {
color: orange;
}
You need to add a class to the active link and #id is not recommended for styling. Also, the pseudo classes that you're using is blocking your desired outcome. Try changing :
#active-home:link,
#active-home:visited {
color: #e88f2a !important;
}
to:
.active {
color: #e88f2a !important;
}
Afterwards, place the .active class into your link code for each page. So for home it would be:
<li class="nav-items active">Home</li>
and for your about page:
<a href="#">
<li class="nav-items">Home</li>
</a>
<a href="about.html">
<li class="nav-items active">About</li>
</a>
and so on...

How can I put <div> over another <div> and insert a rectangle under an image?

Q1
How I can put an image in the center over a background image?
I'm trying to put the image <div class="shape"></div> over the image <div class="hero"></div> within the center. What coding can I add to move it up and down to my needs?
Q2
Below the <div class="shape"></div> image I want to put a rectangle shape box below within the center. Within this CSS what code do I need to add to for me to move the shape up and down. Furthermore, within the CSS would I use height:; & width:; to change the height/width of the box?
HTML
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://placehold.it/60x60" alt="Your Brand Name"></a>
<h1 class="nav-title">Liam Docherty's Digital Portfolio</h1>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Contact
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<section id="section1" class="section1">
<div class="shape"></div>
<div class="hero"></div>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</section>
</body>
CSS
<style>
body {
margin: 0;
padding: 0;
}
.navbar.navbar-default {
background-color: #4D5061;
height: 10vh;
z-index: 100;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: right;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.dropdown-menu li {
text-align:center
}
.dropdown .dropdown-menu {
background-color: #4D5061;
}
.dropdown .dropdown-menu a {
color: white;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: white;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color: #FFFFFF;
border-radius: 9px;
transition: all .2s;
}
.navbar.navbar-default ul li a:hover {
color: white;
}
.nav.navbar-nav,
.nav.navbar-nav>li {
float: none;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
.nav>li>a:hover {
background-color: rgba(17, 17, 17, 0.2);
}
#logo {
padding-top: 2vh;
padding-left: 20px;
float: left;
}
.shape {
content:url(http://i1126.photobucket.com/albums/l611/ldocherty1/IMG_0730_zpsiz4dqc47.jpg);
border-radius: 25px;
background:darkgrey;
color:white;
padding:3px;
margin:50px auto 0 auto;
width:150px;
height:150px;
}
.hero {
background-image: url("https://static.pexels.com/photos/48727/pexels-photo-48727.jpeg");
background-attachment: fixed;
position:absolute;
width: 100%;
width: 100vw;
height: 100%;
height: 70vh;
}
section {
position: relative;
height: 95vh;
}
.section1 {
height: 100vh;
text-align: center;
color: white;
}
.section2 {
//height: 95vh;
background-color: #11B5E4;
text-align: center;
color: white;
}
.section3 {
//height: 95vh;
background-color: #EDF7F6;
text-align: center;
color: white;
}
.fa-angle-down {
color: #4D5061;
position: absolute;
bottom: 0px;
}
.fa-angle-up {
color: #4D5061;
position: absolute;
bottom: 0px;
}
.footer {
height: 5vh;
background-color: #4D5061;
text-align: center;
padding:0;
right:0;
bottom:0;
left:0:
}
.nav-title {
font-size: 14pt;
margin:0;
top: 32px;
left: 50px;
width: 100%;
position: absolute;
text-align: center;
color: white;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul.dropdown-menu li,
.navbar.navbar-default ul.dropdown-menu li a {
position: relative;
display: block;
}
</style>
To put one DIV over another DIV you put the one that should appear on top (= the child) INTO the other one (= the parent element), for example
<div class="x1"><div class="x2">...content...</div></div>
The most important CSS settings for these are:
div.x1 {
position: relative;
}
div.x2 {
position: absolute;
top: 30px;
left: 50px;
width: 100px;
height: 50px;
}
All the px values above are completely random, they depend on your actual situation - adjust them as you need it. But you do need these or similar parameters for the second div.
Also an additional rectangle could handled the same way (like div.x2).
In addition you can assign a background (can be only a color value) to those absolutely positioned DIVs to actually cover what is behind them.
Addition after comment, concerning the codepen:
You did it the other way in HTML - shape has to be inside hero
CSS: absolute/relative: other way around.
For the rest, look at the code in http://codepen.io/anon/pen/JWONgz

How can I change the text color of the nav bar text and center nav bar text?

I was wondering how I can change colour of the nav bar text as it appears and when the user hovers over it? I'm aware I have to use CSS. However, I'm not sure of what class I have to pick from the html. Here is my codepen.
In addition, how can I centre my nav bar text therefore, it's in the centre? I have written the CSS to do all of the requested things. However, the problem identifying the class is my issue. As a result of this, can someone help me with identifying what class name needs to go where in my CSS please.
Furthermore, I have listed my HTML code of the navigation bar below.
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="http://placehold.it/60x60" alt="Your Brand Name"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
<li role="separator" class="divider"></li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
<li role="separator" class="divider"></li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
CSS code below.
<style>
body {
margin: 0;
padding: 0;
}
.navbar.navbar-default {
background-color: #4D5061;
height: 10vh;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: center;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: white;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color:red;
border-radius: 9px;
transition:all .2s;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
a:hover {
color:red;
text-decoration:none;
}
#logo {
padding-top: 2vh;
padding-left: 20px;
float: left;
}
section {
position: relative;
}
.section1 {
height: 90vh;
background-color: #FFFFFF;
text-align: center;
}
.section2 {
height: 95vh;
background-color: #A59E8C;
text-align: center;
color: white;
}
.contact_section {
height: 93vh;
background-color: grey;
}
.logo {
color: #000000;
font-size: 200px;
}
.fa-angle-down {
color: #4D5061;
position: absolute;
bottom: 0px;
}
footer {
height: 10vh;
}
</style>
To change the link hover color, this specificity will overwrite bootstrap's CSS with your existing markup.
.navbar-default.navbar .navbar-nav>li>a:hover {
color: pink;
}
To center the nav text. You already have text-align: center; on .navbar.navbar-default ul and display: inline-block; on .navbar.navbar-default ul li so all you need to do is not float the ul and the li's
.nav.navbar-nav, .nav.navbar-nav>li {
float: none;
}
To change the color of your navbar' links:
.navbar.navbar-default ul li a:hover {
color: green;
}
To center your navbar (replaced my answer by Michael Coker's answer, as his solution is far better):
.nav.navbar-nav, .nav.navbar-nav>li {
float: none;
}
1) If you just inspect it you can see
.navbar-default .navbar-nav>li>a:focus,
.navbar-default .navbar-nav>li>a:hover {
color: #333;
background-color: transparent;
}
which is in "bootstrap.min.css" , so better way to change the color of text on hover is adding your own style like below
.navbar.navbar-default ul li a:hover {
color: white;
}
2) About the second question, I prefer to use "display:flex". I add the style edits below. I hope you will understand.
.navbar.navbar-default>.container-fluid{
display: flex;
justify-content: center;
}
.navbar-header{
margin-right:auto
}
.collapse .navbar-collapse{
margin-right: auto;
}
You have to change .navbar.navbar-default ul li a for the normal font-color.
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: white; <-- There you can change the color
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
To change the hover color (also focus):
.navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover
Be sure to use color: #333 !important; because you overwrite the normal value.
To center your nav bar add this to your css:
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
Source: Center content in responsive bootstrap navbar

Dropdown position Issue [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm working on navbar dropdown menu and him having some trouble trying to position the dropdown menu with a width 100% but when every I put width to 100% it expands to right but not the left side.
Here the link to a preview of my project working on. Hope someone by can help with the small quick problem having.
Preview Link --> https://brandonpowell.github.io/alegacyleftbehind/
This is what trying to accomplish
HTML
<nav class="navbar-default primary-nav navbar-fixed-top nav-down">
<div class="container-fluid">
<div class="row">
<div class="top-navbar">
<div class="media-icons">
<i class="fa fa-facebook-official" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-twitter-square" aria-hidden="true"></i>
</div>
</div>
<a href="#"><div class="donate-button">
<p>Donate</p>
</div></a>
<div class="bottom-navbar">
<div class="logo">Logo Here</div>
<div class="nav-menu"><img src="icons/menu.svg"></div>
<ul class="navbar">
<li>Home</li>
<li>Founder's Message</li>
<li>About Us
<ul class="nav-content">
<li>dropdown item 1</li>
<li>dropdown item 2</li>
<li>dropdown item 3</li>
<li>dropdown item 4</li>
<li>dropdown item 5</li>
<li>dropdown item 6</li>
</ul>
</li>
<li>Join Our Team</li>
<li>News & Events</li>
<li>Campus Clubs</li>
<li>Resources</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
</nav>
CSS
body, html {
margin: 0px;
padding: 0px;
box-sizing: border-box; }
nav .top-navbar {
background-color: #212121;
position: absolute;
height: 67px;
width: 100%; }
.donate-button {
position: relative;
float: right;
top: 0px;
z-index: 1; }
.donate-button p {
font-style: Montserrat, sans-serif;
background-color: #961de7;
letter-spacing: 1px;
padding: 21.4px 35px;
margin-bottom: 0px;
font-weight: bold;
text-transform: uppercase;
color: white; }
.bottom-navbar {
background-color: white;
width: 100%;
display: inline-block;
-webkit-box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2);
box-shadow: 0px 10px 0px rgba(0, 0, 0, 0.2); }
.nav-menu {
display: none; }
.navbar {
display: table; }
.navbar a:hover {
color: pink; }
.navbar li {
display: table-cell;
list-style-type: none;
padding: 0;
margin: 0;
font-size: 14px;
letter-spacing: 0.5px;
font-weight: bold;
text-transform: uppercase; }
.navbar li a {
text-decoration: none;
color: #212121; }
.nav-content {
position: absolute;
top: 13.3em;
z-index: -1;
padding: 1.3em 0 !important;
overflow: hidden;
width: 100%;
background-color: #a656dc; }
.nav-content a {
color: white;
text-decoration: none; }
.logo {
background-color: #961de7;
color: white;
font-size: 16pt;
float: left;
padding: 39px 6%; }
you need to add a value for 'left' to the nav-content div like this:
.nav-content {
position: absolute;
top: 13.3em;
z-index: -1;
padding: 1.3em 0 !important;
overflow: hidden;
width: 100%;
background-color: #a656dc;
left: 0; /*add this*/
}
and to center the menu add margin:auto to the ul element like this:
.nav-content ul {
margin:auto;
}

Dropdown menu without javascript

I have a menu with tabs, and on hover of a tab a list of things appear at the bottom of the tab. Then, I wanted to do that the list of thing go down with a transition( before it was display:block). My problem is that when the transition will start, the top of the list must be a certain multiplication ( the width of a tab * the number of tabs ). But I don't want any javascript.
Is there a way to do that ?
it is my sample of css dropdown menu: i hope be useful:
in HTML, and CSS:
#menu, #menu ul
{
list-style: none;
border: 1px solid #000;
background-color: #ecffec;
padding: 0 0 26px 0;
margin: 0;
}
#menu li
{
float: left;
margin-right: 3px;
border: 1px solid #ecffec;
position: relative;
}
#menu ul
{
position: absolute;
top: 25px;
left: -1px;
width: 200px;
padding: 0;
display: none;
}
#menu ul li
{
float: none;
margin: 0;
padding: 0;
line-height: 15px;
}
#menu a:link, #menu a:visited
{
display: block;
font-family: Tahoma;
font-size: 0.75em;
font-weight: bold;
text-align: left;
text-decoration: none;
color: #000;
padding: 5px;
}
#menu li:hover
{
background-color: #ffd98a;
border: 1px solid #000;
}
#menu li:hover ul
{
display: block;
}
<ul id="menu">
<li>Programming Language
<ul>
<li>Java</li>
<li>PHP</li>
<li>Python</li>
<li>Asp Classic</li>
<li>ASP.NET</li>
<li>javascript</li>
<li>Perl</li>
</ul>
</li>
<li>Database
<ul>
<li>SQL Server 2005</li>
<li>Oracle</li>
<li>MySQL</li>
<li>DB2</li>
</ul>
</li>
<li>Help</li>
</ul>
Have you seen https://codepen.io/markcaron/pen/wdVmpB?
html part
<h2>Checkbox version</h2>
<div class="dropdown">
<input type="checkbox" id="my-dropdown" value="" name="my-checkbox">
<label for="my-dropdown"
data-toggle="dropdown">
Choose one
</label>
<ul>
<li>Coffee</li>
<li>Coverage</li>
<li>Covfefe</li>
</ul>
</div>
<h2>Anchor version</h2>
<div class="dropdown">
<ul id="my-dropdown2">
<li>Coffee</li>
<li>Coverage</li>
<li>Covfefe</li>
</ul>
<a href="#my-dropdown2"
aria-controls="my-dropdown2"
role="button"
data-toggle="dropdown"
id="my-dropdown2-btn">
Choose one
</a>
<a href="#my-dropdown2-btn"
aria-controls="my-dropdown2"
role="button"
data-toggle="dropdown"
class="close">
Close dropdown
</a>
</div>
css part
better to see the link above!
check it out!