This navigation bar I made has drop down menus on certain buttons. I want to make it so when the button that activates the drop down menu is hovered over, the drop down menu sort of falls down into place like this: http://designmodo.com/demo/css3dropdownmenu/
Here's the link to my code: http://jsfiddle.net/w5Ce7/2/
Here's the code just pasted on here:
HTML
<div id="container">
<div id="navbar">
<ul>
<li>Home</li>
<li>Questions</li>
<li>Classes</li>
<li>Designer</li>
<li>Flavors</li>
<li>Cakes
<ul>
<li >Budget Cakes</li>
<li>Wedding
<ul>
<li>Wedding 1</li>
<li>Wedding 2</li>
<li>Wedding 3</li>
<li>Wedding 4</li>
<li>Wedding 5</li>
<li>Wedding 6</li>
</ul>
</li>
<li >Cakes to Go</li>
<li >Cake Bonbons</li>
<li >Holiday Cakes</li>
<li >Cakes for Girls</li>
<li >Cakes for Boys</li>
<li >For Her</li>
<li >For Him</li>
<li >Cupcakes</li>
</ul>
</li>
<li>Events
<ul>
<li>Beach Wedding</li>
<li>Baby Showers</li>
<li>Sweet 15-16</li>
</ul>
</li>
</ul>
</div><!--end of navbar-->
CSS
body {
margin:0;
font-family:Georgia, Arial black, Times, serif;
}
h2 {
text-align:center;
}
img {
border:none;
border:0;
}
#topbanner {
width:100%;
height:40px;
background-color:#88C6CC;
color:#fff;
text-align:center;
line-height:40px;
font-size:36px;
}
#container {
width:1050px;
height:800px;
background-color:#B7E6E8;
margin:auto;
position:relative;
border-radius:20px;
-moz-border-radius:20px;
-webkit-border-radius:20px;
-ms-border-radius:20px;
-o-border-radius:20px;
margin-top:10px;
}
/*Start Navigation Bar*/
#navbar ul ul {
display:none;
}
#navbar ul li:hover > ul {
display:block;
}
#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}
#navbar ul:after {
content: ""; clear: both; display: block;
}
#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
}
#navbar ul li:hover {
background:#4b545f;
}
#navbar ul li:hover a {
color:#fff;
}
#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}
#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
width:195px;
z-index:1;
}
#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
}
#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}
#navbar ul ul li a:hover {
background: #4b545f;
}
#navbar {
text-align:center;
}
#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}
There you go. FIDDLE. The problem was displaying sub ul's as block.
#navbar ul li:hover > ul {
opacity:1;
height:auto !Important;
}
#navbar ul li:hover > ul > li {
height:50px !important;
opacity:1;
}
#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}
#navbar ul:after {
content:"";
clear: both;
display: block;
}
#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
position:relative;
}
#navbar ul li:hover {
background:#4b545f;
}
#navbar ul li:hover a {
color:#fff;
}
#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}
#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
left:0px;
width:195px;
z-index:1;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
height:0px;
}
#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
height:0px;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
}
#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}
#navbar ul ul li a:hover {
background: #4b545f;
}
#navbar {
text-align:center;
}
#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}
Related
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
With this code I have problems because just I have this and I want that those submenus comes over the all menu and then we can select it
If we can see Promedio 2 and promedio 3 are behind of or menu
#charset "utf-8";
#menu2,
#menu2 ul,
#menu2 li,
#menu2 a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
/* menu2 */
#menu2 {
width:850px;
height:33px;
margin:0px;
padding:0px;
font-size:13px;
vertical-align:top;
float:left;
border-top-right-radius:10px;
/*background: -webkit-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -moz-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -o-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -ms-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: linear-gradient(top, #7b0100 0%,#7b0100 100%);
*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#menu2 li:hover{
background:#000066;
color:#FF0;
}
#li_menu{
width:80px;
text-align:center;
padding:0px;
margin:0px;
}
#li_submenu{
text-align:left;
}
#menu2 li {
position: relative;
list-style: none;
float: left;
display: block;
height: 34px;
}
/* Links */
#menu2 li a {
display: block;
padding: 0 14px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
border-left: 1px solid #CCC;
border-right: 1px solid #9000;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #FFFFFF;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
#menu2 li:first-child a { border-left: none; }
#menu2 li:last-child a{ border-right: none; }
#menu2 li:hover > a { color: #FFFF00; }
/* Sub menu2 */
#menu2 ul {
position: absolute;
top: 40px;
left: 0;
opacity: 0;
background: #0000FF;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
#menu2 li:hover > ul {
opacity: 1;
}
#menu2 ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
#menu2 li:hover > ul li {
height: 34px;
overflow: visible;
padding: 0;
}
#menu2 ul li a {
width: 120px;
padding: 4px 0 4px 30px;
margin: 0;
border: none;
border-bottom: 1px solid #4F0002;
}
+++++++++++++++
#menu, #menu ul {
list-style:none;
padding:0;
margin:0;
}
#menu li {
float:center;
position:relative;
line-height: 4.5em;
width: 10em;
}
#menu li ul {
position:absolute;
margin-top:-1em;
margin-left:.5em;
display:none;
}
#menu ul li ul {
margin-top:-3em;
margin-left:7em;
}
#menu a {
display:block;
border-right:0px solid #fff;
color:#FFFFFF;
text-decoration:none;
padding:0 10px;
}
#menu a:hover {
background-color:#0000FF;
color:#fff;
}
#menu ul {
border-top:1px solid #fff;
}
#menu ul a {
border-right:none;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
background:#0000FF;
}
/* SHOW SUBMENU 1 */
#menu li:hover ul, #menu li.over ul {
display:block;
position: absolute;
}
#menu li:hover ul ul, #menu li.over ul ul {
display:none;
}
/* SHOW SUBMENU 2 */
#menu ul li:hover ul, #menu ul li.over ul {
display:block;
}
+++++++++++++++++++++++++++++++++
<li id="menu">Examenes
<ul>
<li id="menu"><a href="#" >Calendario</a>
<ul id="menu li.over ul">
<li id="menu"><a href="#" >Calendario 1</a>
<ul id="menu li.over ul">
<li id="menu2_ul_li_a"><a href="examen2.php" tag=location_entry>Matematicas</a>
<ul id="menu2_ul_li_a">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Fisica
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>E. Fisica
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Artisticas
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Historia
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Taller
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Biologia
<ul>
<li><a href="examen2.php" >1</a></li>
<li><a href="examen2.php" >2</a></li>
<li><a href="examen2.php" >3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="menu"><a href="#" >Promedio 1ero</a>
<ul id="menu li.over ul">
<li id="menu">Español</li>
<li id="menu">Matematicas</li>
<li id="menu li">Fisica</li>
<li id="menu li">E. Fisica</li>
<li id="menu2 li:hover > ul ">Artisticas</li>
<li id="menu li">Historia</li>
<li id="menu li">Taller</li>
<li id="menu li">Biologia</li>
</ul>
</li>
<li id="menu">Segundo
<ul id="menu li.over ul">
<li>Español</li>
<li>Matematicas</li>
<li>Fisica</li>
<li>E. Fisica</li>
<li>Artisticas</li>
<li>Historia</li>
<li>Taller</li>
<li>Biologia</li>
</ul>
</li>
<li id="menu">Tercero
<ul id="menu li.over ul">
<li>Español</li>
<li>Matematicas</li>
<li>Fisica</li>
<li>E. Fisica</li>
<li>Artisticas</li>
<li>Historia</li>
<li>Taller</li>
<li>Biologia</li>
</ul>
</li>
</ul>
</li>
#menu2,
#menu2 ul,
#menu2 li,
#menu2 a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
/* menu2 */
#menu2 {
width:850px;
height:33px;
margin:0px;
padding:0px;
font-size:13px;
vertical-align:top;
float:left;
border-top-right-radius:10px;
/*background: -webkit-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -moz-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -o-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -ms-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: linear-gradient(top, #7b0100 0%,#7b0100 100%);
*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#menu2 li:hover{
background:#000066;
color:#FF0;
}
#li_menu{
width:80px;
text-align:center;
padding:0px;
margin:0px;
}
#li_submenu{
text-align:left;
}
#menu2 li {
position: relative;
list-style: none;
float: left;
display: block;
height: 34px;
}
/* Links */
#menu2 li a {
display: block;
padding: 0 14px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
border-left: 1px solid #CCC;
border-right: 1px solid #9000;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #FFFFFF;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
#menu2 li:first-child a { border-left: none; }
#menu2 li:last-child a{ border-right: none; }
#menu2 li:hover > a { color: #FFFF00; }
/* Sub menu2 */
#menu2 ul {
position: absolute;
top: 40px;
left: 0;
opacity: 0;
background: #0000FF;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
#menu2 li:hover > ul {
opacity: 1;
}
#menu2 ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
#menu2 li:hover > ul li {
height: 34px;
overflow: visible;
padding: 0;
}
#menu2 ul li a {
width: 120px;
padding: 4px 0 4px 30px;
margin: 0;
border: none;
border-bottom: 1px solid #4F0002;
}
+++++++++++++++
#menu, #menu ul {
list-style:none;
padding:0;
margin:0;
}
#menu li {
float:center;
position:relative;
line-height: 4.5em;
width: 10em;
}
#menu li ul {
position:absolute;
margin-top:-1em;
margin-left:.5em;
display:none;
}
#menu ul li ul {
margin-top:-3em;
margin-left:7em;
}
#menu a {
display:block;
border-right:0px solid #fff;
color:#FFFFFF;
text-decoration:none;
padding:0 10px;
}
#menu a:hover {
background-color:#0000FF;
color:#fff;
}
#menu ul {
border-top:1px solid #fff;
}
#menu ul a {
border-right:none;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
background:#0000FF;
}
/* SHOW SUBMENU 1 */
#menu li:hover ul, #menu li.over ul {
display:block;
position: absolute;
}
#menu li:hover ul ul, #menu li.over ul ul {
display:none;
}
/* SHOW SUBMENU 2 */
#menu ul li:hover ul, #menu ul li.over ul {
display:block;
}
+++++++++++++++++++++++++++++++++
Some important notes:
You really need to clean it up.
Do not repeat id's. They are meant to
be unique.
float: center does not exist
classes with a dot (li.over) are not well supported. Use - or _ (li-over,li_over)
there is more than one way to do this. Here is one. On this solution, you add the class has-submenu to the list element with a submenu
I'm new using html5 and css3. I'm trying to create a basic web for a final project.
Basically I need a menu on the left side (fixed position) + input button in the top - center position + div in which to display all content uploaded (text file).
Here is the fiddle of the full code: FIDDLE
As you can see, the menu scrolls down.
CSS:
*{
margin:0;
padding:0;
}
body {
background-color:#bababa;
color:#fff;
}
div#fileOutput{
margin: auto;
margin-top: 50px;
margin-left: 400px;
margin-right: 50px;
margin-bottom: 50px;
width: 960px;
height: 800px;
white-space: pre-line;
border: solid 1px black;
padding: 5px;
}
input[type="file"]{
margin: auto;
width: 960px;
height: 50px;
margin-left: 400px;
white-space: pre-line;
border: solid 1px black;
padding: 5px;
}
#nav {
border:3px solid #3e4547;
box-shadow:2px 2px 8px #000000;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
#nav, #nav ul {
list-style:none;
padding:0;
width:200px;
}
#nav ul {
position:relative;
z-index:-1;
}
#nav li {
position:relative;
z-index:100;
}
#nav ul li {
margin-top:-23px;
-moz-transition: 0.4s linear 0.4s;
-ms-transition: 0.4s linear 0.4s;
-o-transition: 0.4s linear 0.4s;
-webkit-transition: 0.4s linear 0.4s;
transition: 0.4s linear 0.4s;
}
#nav li a {
background-color:#d4d5d8;
color:#000;
display:block;
font-size:12px;
font-weight:bold;
line-height:28px;
outline:0;
padding-left:15px;
text-decoration:none;
}
#nav li a.sub {
background:#d4d5d8 url("../images/down.gif") no-repeat;
}
#nav li a + img {
cursor:pointer;
display:none;
height:28px;
left:0;
position:absolute;
top:0;
width:200px;
}
#nav li a img {
border-width:0px;
height:24px;
line-height:28px;
margin-right:8px;
vertical-align:middle;
width:24px;
}
#nav li a:hover {
background-color:#bcbdc1;
}
#nav ul li a {
background-color:#eee;
border-bottom:1px solid #ccc;
color:#000;
font-size:11px;
line-height:22px;
}
#nav ul li a:hover {
background-color:#ddd;
color:#444;
}
#nav ul li a img {
background: url("../images/bulb.png") no-repeat;
border-width:0px;
height:16px;
line-height:22px;
margin-right:5px;
vertical-align:middle;
width:16px;
}
#nav ul li:nth-child(odd) a img {
background:url("../images/bulb2.png") no-repeat;
}
#nav a.sub:focus {
background:#bcbdc1;
outline:0;
}
#nav a:focus ~ ul li {
margin-top:0;
-moz-transition: 0.4s linear;
-ms-transition: 0.4s linear;
-o-transition: 0.4s linears;
-webkit-transition: 0.4s linears;
transition: 0.4s linear;
}
#nav a:focus + img, #nav a:active + img {
display:block;
}
#nav a.sub:active {
background:#bcbdc1;
outline:0;
}
#nav a:active ~ ul li {
margin-top:0;
}
#nav ul:hover li {
margin-top:0;
}
Expected result:
Any suggestions? Thank you so much.
The CSS change:
#nav {
position: fixed;
top: 0; left: 0;
}
Snippet:
*{
margin:0;
padding:0;
}
body {
background-color:#bababa;
color:#fff;
}
div#fileOutput{
margin: auto;
margin-top: 50px;
margin-left: 250px;
margin-right: 50px;
margin-bottom: 50px;
width: 960px;
height: 800px;
white-space: pre-line;
border: solid 1px black;
padding: 5px;
}
input[type="file"]{
margin: auto;
width: 960px;
height: 50px;
margin-left: 250px;
white-space: pre-line;
border: solid 1px black;
padding: 5px;
}
#nav {
border:3px solid #3e4547;
box-shadow:2px 2px 8px #000000;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
position: fixed;
top: 0; left: 0;
}
#nav, #nav ul {
list-style:none;
padding:0;
width:200px;
}
#nav ul {
position:relative;
z-index:-1;
}
#nav li {
position:relative;
z-index:100;
}
#nav ul li {
margin-top:-23px;
-moz-transition: 0.4s linear 0.4s;
-ms-transition: 0.4s linear 0.4s;
-o-transition: 0.4s linear 0.4s;
-webkit-transition: 0.4s linear 0.4s;
transition: 0.4s linear 0.4s;
}
#nav li a {
background-color:#d4d5d8;
color:#000;
display:block;
font-size:12px;
font-weight:bold;
line-height:28px;
outline:0;
padding-left:15px;
text-decoration:none;
}
#nav li a.sub {
background:#d4d5d8 url("../images/down.gif") no-repeat;
}
#nav li a + img {
cursor:pointer;
display:none;
height:28px;
left:0;
position:absolute;
top:0;
width:200px;
}
#nav li a img {
border-width:0px;
height:24px;
line-height:28px;
margin-right:8px;
vertical-align:middle;
width:24px;
}
#nav li a:hover {
background-color:#bcbdc1;
}
#nav ul li a {
background-color:#eee;
border-bottom:1px solid #ccc;
color:#000;
font-size:11px;
line-height:22px;
}
#nav ul li a:hover {
background-color:#ddd;
color:#444;
}
#nav ul li a img {
background: url("../images/bulb.png") no-repeat;
border-width:0px;
height:16px;
line-height:22px;
margin-right:5px;
vertical-align:middle;
width:16px;
}
#nav ul li:nth-child(odd) a img {
background:url("../images/bulb2.png") no-repeat;
}
#nav a.sub:focus {
background:#bcbdc1;
outline:0;
}
#nav a:focus ~ ul li {
margin-top:0;
-moz-transition: 0.4s linear;
-ms-transition: 0.4s linear;
-o-transition: 0.4s linears;
-webkit-transition: 0.4s linears;
transition: 0.4s linear;
}
#nav a:focus + img, #nav a:active + img {
display:block;
}
#nav a.sub:active {
background:#bcbdc1;
outline:0;
}
#nav a:active ~ ul li {
margin-top:0;
}
#nav ul:hover li {
margin-top:0;
}
<body>
<input id="fileInput" placeholder=":input" type="file" size="50" onchange="processFiles(this.files)">
<div id="fileOutput"></div>
<!--<div id="parseOutput" style="white-space: pre-line;"></div>-->
<div class="container">
<ul id="nav">
<li><img src="images/t1.png" /> Home</li>
<li><img src="images/t2.png" />HTML/CSS<img src="images/up.gif" alt="" />
<ul>
<li><img src="images/empty.gif" />Link 1</li>
<li><img src="images/empty.gif" />Link 2</li>
<li><img src="images/empty.gif" />Link 3</li>
<li><img src="images/empty.gif" />Link 4</li>
<li><img src="images/empty.gif" />Link 5</li>
</ul>
</li>
<li><img src="images/t3.png" />jQuery/JS<img src="images/up.gif" alt="" />
<ul>
<li><img src="images/empty.gif" />Link 6</li>
<li><img src="images/empty.gif" />Link 7</li>
<li><img src="images/empty.gif" />Link 8</li>
<li><img src="images/empty.gif" />Link 9</li>
<li><img src="images/empty.gif" />Link 10</li>
</ul>
</li>
<li><img src="images/t2.png" />PHP</li>
<li><img src="images/t2.png" />MySQL</li>
<li><img src="images/t2.png" />XSLT</li>
</ul>
</div>
</body>
*
I don't know what I am doing wrong here so can you help me? I want to create a cascading drop-down menu and I can't see what I am doing wrong. I've tried everything. I am just out of ideas
*
HERE IS MY CODE
<style type="text/css">
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
</style>
</body>
</html>
<html>
<head>
<title> Australia </title>
</head>
<body>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
You can use adjacent sibling selector for more info visit this link On a CSS hover event, can I change another div's styling?
Set display:none initially to sub-menu1 class and on hover of sub-menu li a set display of adjacent sub-menu1 back to block.
Here is the code:
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
display: block;
}
.sub-menu li a:hover + .sub-menu1{
display:block;
padding:10px 10px;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
Or you can have an indentation on your submenus? It really depends on what you want. Could you give some example? Here's what I meant when I was talking about indentation :
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>
Sydney
<ul>
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
First of all,you must write 0 instead of 0px.
you must make the sub-menu1 display: none; then when mouse is on sydney the sub-menu must be display: block;
i have fixed somethings and this will be your code:
body {
background: #bf5c71;
}
.clearfix:after {
display: block;
clear: both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width: 100%;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
background: #3e3436;
}
.menu {
width: 1000px;
margin: 0 auto;
}
.menu li {
margin: 0;
list-style: none;
font-family: 'Ek Mukta';
}
.menu a {
transition: all linear 0.15s;
color: #919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration: none;
color: #be5b70;
}
.menu .arrow {
font-size: 11px;
line-height: 0;
}
/*----- Top Level -----*/
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1 {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0;
position: absolute;
top: 0;
left: 0;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
#sydney:hover .sub-menu1 {
display: block;
}
.sub-menu1 {
width: 100%;
padding: 0;
position: relative;
top: 0;
left: 370px;
z-index: 100;
opacity: 50;
transition: opacity linear .15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li {
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a {
background: #3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li id="sydney">Sydney
<ul class="sub-menu1">
<li>Test</li>
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
Can someone please help me? I'm trying to center my navigation menu. I have tried different things, but nothing works, and i really don't know what to do. I would really appreciate help. thanks in advance!
nav {
display: inline-block;
list-style-type: none;
float: left;
width: 100%;
height: 102px;
text-align: center;
}
nav > ul {
float:right;
width:100%;
height:102px;
background:#222;
border-radius: 10px 10px 0px 0px;
}
nav > ul > li {
float:left;
width:auto;
margin-right:10px;
line-height:102px;
}
nav > ul li a {
padding:50px;
color:white;
font-family:helvetica, sans-serif;
}
nav > ul > li > ul {
background:#222;
opacity:0;
transition:opacity 1s;
-webkit-transition:opacity 1s;
-moz-transition:opacity 1s;
-o-transition:opacity 1s;
-ms-transition:opacity 1s;
border-radius: 0px 0px 10px 10px;
}
nav > ul > li:hover > ul {
opacity:1;
}
HTML
<div>
<nav>
<ul>
<li> Hjem
<ul>
<li>Sub1</li>
<li>Sub2</li>
<li>Sub3</li>
</ul>
</li>
<li>Bilder</li>
<li>Video</li>
<li>Design</li>
</ul>
</nav>
</div>
Here is what I did.
#outer{
width:100%;
height: 102px;
text-align: center;
background:#222;
border-radius: 10px 10px 0px 0px;
}
nav {
display: inline-block;
list-style-type: none;
margin: 0 auto;
}
nav > ul > li {
float:left;
width:auto;
margin-right:10px;
line-height:102px;
}
nav > ul li a {
padding:50px;
color:white;
font-family:helvetica, sans-serif;
}
nav > ul > li > ul {
background:#222;
opacity:0;
transition:opacity 1s;
-webkit-transition:opacity 1s;
-moz-transition:opacity 1s;
-o-transition:opacity 1s;
-ms-transition:opacity 1s;
border-radius: 0px 0px 10px 10px;
}
nav > ul > li:hover > ul {
opacity:1;
}
And you just need to give an ID to the div.
<div id="outer">
Whenever I hover my mouse under the buttons that have drop down menus, the drop down menu shows. I want to make it so the drop down menu only shows when I put my mouse over the actual button.
FIDDLE CODE
HTML
<div id="navbar">
<ul>
<li>Home</li>
<li>Cakes
<ul>
<li >Budget Cakes</li>
<li>Wedding</li>
<li >Cakes to Go</li>
<li >Cake Bonbons</li>
<li >Holiday Cakes</li>
<li >Cakes for Girls</li>
<li >Cakes for Boys</li>
<li >For Her</li>
<li >For Him</li>
<li >Cupcakes</li>
</ul>
</li>
<li>Classes</li>
<li>Flavors</li>
<li>Events
<ul>
<li>Beach Wedding</li>
<li>Baby Showers</li>
<li>Sweet 15-16</li>
</ul>
</li>
<li>Contact</li>
<li>Questions</li>
</ul>
</div><!--end of navbar-->
CSS
#navbar ul li:hover > ul {
height:auto !important;
opacity:1;
}
#navbar ul li:hover > ul > li {
height:50px !important;
opacity:1;
}
#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}
#navbar ul:after {
content:"";
clear: both;
display: block;
}
#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
position:relative;
}
#navbar ul li:hover {
background:#4b545f;
}
#navbar ul li:hover a {
color:#fff;
}
#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}
#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
left:0px;
width:195px;
z-index:1;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
height:0px;
}
#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
height:0px;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
}
#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}
#navbar ul ul li a:hover {
background: #4b545f;
}
#navbar {
text-align:center;
}
#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}
It's because your nested <ul> still has a height, and so when you hover on it, the browser considers that as hovering on part of the first <li>.
Easiest way to fix it is to set the subnav ul to display: block and overflow: hidden.
#navbar ul ul {
...(existing styles)
display: block;
overflow: hidden;
}
Demo
Alternatively, you can toggle visibility: hidden.
#navbar ul ul {
...(existing styles)
visibility: hidden; /* ADD */
}
#navbar ul li:hover > ul {
...(existing styles)
visibility: visible; /* ADD */
}
Demo 2
Add following CSS.
#navbar ul ul {
display: block;
overflow: hidden;
}