I'm new to programming web and I made this small submenu and works properly in Mozilla, but in IE when I run the submenu disappears.
Why is this only happens in IE?
I use IE11
Code:
http://jsfiddle.net/4nLabpon/
or:
<div id="grad1">
<div class="wrapper">
<div class="menu-holder">
<ul class="menu">
<li class="active">
<a class="test" href="#">Planning</a>
<ul class="submenu">
<li>Add Products
</li>
<li>Add Clients
</li>
<li>Deadline
</li>
</ul>
</li>
<li>Sells
</li>
</ul>
</div>
<!-- menu-holder end -->
</div>
</div>
CSS
#grad1 {
height: auto;
background-color: grey;
}
.wrapper {
width:600px;
height:30px;
opacity:0.9;
margin:0 auto;
}
.menu-holder ul {
margin: 2px 0 0px 25px;
padding: 0;
list-style-type: none;
}
.menu-holder ul li {
position: relative;
float: left;
padding: 0px 10px 0 10px;
margin: 0px 0px 100px 0px;
border-left: 1px dotted white;
line-height: 0px;
}
.menu-holder ul li:hover > a {
background-color: #1b597d;
}
.menu-holder ul li:hover ul {
display: block;
}
.menu-holder ul li a {
font-family: arial, sans-serif;
font-size: 12px;
font-weight: bold;
display: block;
color: white;
text-decoration: none;
padding: 15px 10px 15px 10px;
-webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;
}
.menu-holder ul li ul {
float: none;
display: none;
position: absolute;
top: 40px;
left: 0px;
margin: -1px 0 0px 10px;
padding: 5px 10px 5px 10px;
white-space: nowrap;
}
.menu-holder ul li ul:hover {
display: block;
}
.menu-holder ul li ul li {
position: static;
float: none;
display: inline;
padding: 5px 10px 5px 10px;
margin: 0px 0px 0px -10px;
background-color: #1b597d;
}
.menu-holder ul li ul li a {
display: inline;
margin: 0 0px 0 0px;
padding: 0px 10px 0px 10px;
font-weight: normal;
-webkit-border-radius: 0;
border-radius: 0;
}
.menu-holder ul li ul li:first-of-type {
-webkit-border-radius: 0px 0px 0px 5px;
border-radius: 0px 0px 0px 5px;
}
.menu-holder ul li ul li:last-of-type {
-webkit-border-radius: 0px 5px 5px 0px;
border-radius: 0px 5px 5px 0px;
}
.menu-holder ul li:first-of-type {
border-left: none;
}
Thank you all
Try this code
<div class="wrapper">
<ul class="menu">
<li class="active"><a class="test" href="#">Planning</a>
<ul class="submenu">
<li>Add Products</li>
<li>Add Clients</li>
<li>Deadline</li>
</ul>
</li>
<li>Sells</li>
</ul>
</div>
Css Style :
.wrapper{
float:left;
width:100%;
position:relative;
background:#0066CC;
color:#fff;
}
ul.menu{
float:left;
width:100%;
list-style:none;
color:#000000;
}
ul li a{
color:#000;
text-decoration:none;
padding:5px;
}
ul.menu li{
display:inline-block;
float:left;
margin-right:5px;
background:#cccccc;
color:#ff6600;
}
ul.menu li > ul{
float:left;
position:absolute;
width:auto;
margin-top:0px;
left:0px;
display:none;
}
ul.menu li > ul li{
margin:0;
}
ul.menu li:hover > ul{
display:block;
}
Related
I'm trying to create a basic drop-down menu. Whenever I however over "blog", the "wiki" link seems to get dragged into it.
Here's a screenshot to show what I mean:
As you can see, "wiki" is below "march". I want to have "march" drop down from "blog" and keep "wiki" along the green line.
#header {
box-shadow: 0px 0px 5px 2px #000;
border-radius: 15px 15px 15px 15px;
width: 790px;
height: 30px;
line-height: 85%;
background: #002929;
word-spacing: 5px;
}
#header li {
display: inline;
}
#header ul ul {
display: none;
}
#header ul li:hover > ul {
display: block;
}
#header a:hover {
background: #0147FA;
border-radius: 15px 15px 15px 15px;
padding: 2px;
}
#header a {
text-decoration: none;
color: #ffff4c;
}
<div id="header">
<ul>
<li style="font-size:30px"><strong>Home</strong></li>
<li style="font-size:30px"><strong>Blog</strong>
<ul>
<li style="font-size:30px"><strong>March</strong></li>
</ul>
</li>
<li style="font-size:30px"><strong>Wiki</strong></li>
</ul>
</div>
Here's a JSFiddle.
So I cleaned up the css and it seems to work now.
Here is your html below
<div id="header">
<ul>
<li style="font-size:30px"><strong>Home</strong></li>
<li style="font-size:30px"><strong>Blog</strong>
<ul>
<li style="font-size:30px"><strong>March</strong></li>
</ul>
</li>
<li style="font-size:30px"><strong>Wiki</strong></li>
</ul>
</div>
Here is the new css below:
#header {
box-shadow: 0px 0px 5px 2px #000;
border-radius:15px 15px 15px 15px;
width: 790px;
height: 30px;
line-height: 85%;
background: #002929;
word-spacing: 5px;
}
#header li {
display: inline;
}
#header a:hover {
background: #0147FA;
border-radius: 15px 15px 15px 15px;
}
#header a {
text-decoration: none;
color: #ffff4c;
}
#header ul a
{
text-decoration:none;
font-weight:700;
line-height:32px;
padding:0 15px;
}
#header ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#header ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
padding:0
}
#header ul li:hover > ul
{
display:block
}
Be sure to compare to see the differences between your css and my css. If this is is not what you wanted please get back to me.
I have simply HTML + CSS menu.
https://dl.dropboxusercontent.com/u/73908828/ccs_help/home.html
<head>
<style>
*, body {
padding:0px;
margin: 0px;
font-family: "Arial";
}
#line {
position: absolute;
height:62px;
width: 100%;
top: 408px;
z-index:1;
border-top: 1px solid #636363;
border-bottom: 2px solid #393939;
background-color: #0a0c0c;
-webkit-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 1);
-moz-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 1);
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 1);
}
#menu-box, #menu {
width: 990px;
display: block;
margin-left: auto;
margin-right: auto;
}
#menu {
height:62px;
}
#menu ul.c {
list-style-type: none;
}
#center ul a.c {
font-size: 34px;
font-weight: bold;
line-height: 65px;
letter-spacing: 0px;
display: block;
padding-left: 30px;
padding-right: 30px;
background-repeat: no-repeat;
background-position: right;
text-decoration: none;
color: #505050;
}
#center ul a.c:hover {
color: #038aff;
}
ul#nav {
margin: 0;
padding: 0;
list-style: none;
}
ul#nav li {
display: inline;
}
ul#nav li a {
float: left;
line-height: 40px;
text-decoration: none;
}
ul#nav .current a, ul#nav li:hover > a {
text-decoration: none;
}
ul#nav ul {
display: none;
}
ul#nav li:hover > ul {
position: absolute;
display: block;
margin: 65px 0 0 0;
font-size: 14px;
letter-spacing: 1px;
color: #a4a4a4;
float:left;
left:50%;
text-align:center;
}
ul#nav li:hover > ul li {
position:relative;
right:50%;
display: table;
}
ul#nav li:hover > ul li a {
float: left;
text-decoration: none;
}
ul#nav li:hover > ul li a:hover {
text-decoration: none;
text-shadow: none;
}
.submenu {
background-color: #000;
display:table-cell;
vertical-align: middle;
border-bottom: 1px solid #393939;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="line">
<div id="menu-box">
<div id="center">
<ul id="nav" class="c">
<li><a id="products" href="javascript:;" class="c" style="padding-left:0px;">PRODUCTS</a>
<ul>
<li class="outer">
<div class="submenu-left"></div>
<div class="submenu">SECOND_PRODUCTS</div>
<div class="submenu-right"></div>
</li>
</ul>
</li>
<li>MAIN_SUPPORT
<ul>
<li class="outer">
<div class="submenu-left"></div>
<div class="submenu">SECOND_SUPPORT</div>
<div class="submenu-right"></div>
</li>
</ul>
</li>
<li><a id="sale" href="javascript:;" class="c" style="background-image: none; padding-right: 0px;">DISTRIBUTION</a>
<ul>
<li class="outer">
<div class="submenu-left"></div>
<div class="submenu">SECOND_DISTRIBUTION</div>
<div class="submenu-right"></div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div id="main">
<div class="lgflags"></div>
<div class="img"></div>
</div>
</body>
My question is, how I make it so that second menu will always be displayed even if there will be no mouse hover? I need last hover menu always visible.
I use only HTML and CSS but if necessary, can be used JavaScript or jQuery.
Apply the hover styling to your second menu using
nth-child(2)
For example,
ul#nav li:hover > ul, ul#nav li:nth-child(2)> ul {
position: absolute;
display: block;
margin: 65px 0 0 0;
font-size: 14px;
letter-spacing: 1px;
color: #a4a4a4;
float:left;
left:50%;
text-align:center;
}
Iam working on a pure html/css menu with horizontal submenu, but the hover is not working properly in Internet Explorer. When you hover over the submenu it disappears...
In Chrome and Firefox everything works fine.
Here is a jfiddle:
http://jsfiddle.net/te5AU/2/
And here is the code:
<div class="wrapper">
<div class="menu-holder">
<ul class="menu">
<li>item 1
</li>
<li class="active"><a class="test" href="#">This is the one</a>
<ul class="submenu">
<li>Submenu item 1
</li>
<li>Submenu item 2
</li>
</ul>
</li>
<li>menu item 3
</li>
<li>menu item 4
</li>
</ul>
</div>
<!-- menu-holder end -->
</div>
Here is the css:
.wrapper {
width:500px;
height:500px;
background:grey;
}
.menu-holder ul {
margin: 2px 0 0px 25px;
padding: 0;
list-style-type: none;
}
.menu-holder ul li {
position: relative;
float: left;
padding: 0px 10px 0 10px;
margin: 0px 0px 100px 0px;
border-left: 1px dotted white;
line-height: 0px;
}
.menu-holder ul li:hover > a {
background-color: #025179;
}
.menu-holder ul li:hover ul {
display: block;
}
.menu-holder ul li a {
font-family: arial, sans-serif;
font-size: 12px;
font-weight: bold;
display: block;
color: white;
text-decoration: none;
padding: 15px 10px 15px 10px;
-webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;
}
.menu-holder ul li ul {
float: none;
display: none;
position: absolute;
top: 40px;
left: 0px;
margin: -1px 0 0px 10px;
padding: 5px 10px 5px 10px;
white-space: nowrap;
}
.menu-holder ul li ul:hover {
display: block;
}
.menu-holder ul li ul li {
position: static;
float: none;
display: inline;
padding: 5px 10px 5px 10px;
margin: 0px 0px 0px -10px;
background-color: #025179;
}
.menu-holder ul li ul li a {
display: inline;
margin: 0 0px 0 0px;
padding: 0px 10px 0px 10px;
font-weight: normal;
-webkit-border-radius: 0;
border-radius: 0;
}
.menu-holder ul li ul li:first-of-type {
-webkit-border-radius: 0px 0px 0px 5px;
border-radius: 0px 0px 0px 5px;
}
.menu-holder ul li ul li:last-of-type {
-webkit-border-radius: 0px 5px 5px 0px;
border-radius: 0px 5px 5px 0px;
}
.menu-holder ul li:first-of-type {
border-left: none;
}
li is not getting proper height in IE. U should remove
.menu-holder ul li { line-height: 0} //remove the css line-height: 0;
and then try.
Try this:
http://jsfiddle.net/te5AU/4/
HI i have some changing in you css
.menu-holder > ul > li:hover > a {
background-color: #025179;
}
.menu-holder ul li ul {
float: none;
display: none;
position: absolute;
margin:0; top: 30px;padding:0;
left: 10;
white-space: nowrap;font-size:0;
}
.menu-holder ul li ul li {
position: static;
float: none;
display: inline-block;
padding:0;
margin:0px;font-size:14px;
background-color: #025179;
}
.menu-holder ul li ul li a {
display:block;
margin: 0 0px 0 0px;
padding: 0 10px;
line-height:30px;
font-weight: normal;
-webkit-border-radius: 0;
border-radius: 0;
}
Demo
I am building a pure HTML/CSS menu with a horizontal submenu.
The problem is that when you are hovering on the submenu the background color from the hover of the main-menu item is gone.
Is it possible to keep that background color of the main menu item when you are hovering on the submenu?
Here is what I got so far:
http://jsfiddle.net/YKEkB/1/
As you can see when you hover over "this is the one" you get the submenu. But when you are in the submenu the background color of "this is the one" changes back.
Is there any solution with pure HTML/CSS?
This is all the code:
<div class="wrapper">
<div class="menu-holder">
<ul class="menu">
<li>item 1
</li>
<li><a class="test" href="#">This is the one</a>
<ul class="submenu">
<li>Submenu item 1
</li>
<li>Submenu item 2
</li>
</ul>
</li>
<li><a href="#" >Menu item 3</a>
</li>
<li><a href="#" >Last item</a>
</li>
</ul>
</div>
</div>
css:
.wrapper {
width:900px;
height:200px;
background:grey;
}
.menu-holder {
padding: 50px 0 0 0;
}
.menu-holder ul {
margin: 0 0 0px 25px;
padding: 0;
list-style-type: none;
}
.menu-holder ul li {
position: relative;
float: left;
padding: 0px 10px 0 10px;
margin: 0px 0 0 0px;
border-left: 1px dotted white;
line-height: 0px;
}
.menu-holder ul li a {
font-family: arial, sans-serif;
font-size: 12px;
font-style: bold;
display: block;
color: white;
text-decoration: none;
padding: 15px 10px 15px 10px;
-webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;
}
.menu-holder ul li a:hover + ul {
display: block;
}
.menu-holder ul li a:hover {
display: block;
background-color: #025179;
}
.menu-holder ul li .submenu {
display: none;
position: absolute;
top: 100%;
left: 0px;
right: auto;
margin: -5px 0 0px 0px;
padding: 5px 10px 5px 10px;
white-space: nowrap;
}
.menu-holder ul li .submenu li {
position: static;
float: left;
display: inline;
padding: 15px 10px 15px 10px;
background-color: #025179;
}
.menu-holder ul li .submenu li a {
display: inline;
margin: 0 0px 0 0px;
padding: 0px 10px 0px 10px;
-webkit-border-radius: 0;
border-radius: 0;
}
.menu-holder ul li .submenu li:first-of-type {
-webkit-border-radius: 0px 0px 0px 5px;
border-radius: 0px 0px 0px 5px;
}
.menu-holder ul li .submenu li:last-of-type {
-webkit-border-radius: 0px 5px 5px 0px;
border-radius: 0px 5px 5px 0px;
}
.menu-holder ul li .submenu:hover {
display: block;
}
.menu-holder ul li .submenu:hover .test {
display: block;
background-color: #025179;
}
.menu-wrapper .menu-holder ul li:first-of-type {
border-left: none;
}
Easy: http://jsfiddle.net/YKEkB/2/
You have to change it to this (delete the a):
.menu-holder ul li:hover{
display: block;
background-color: #025179;
}
Now you will have to adjust it so it's centered vertically. Note that you should keep 0px between the menu item and the submenu.
Many more things.
You can use the pseudo element :last-child to add the dotted line in the last item (see fiddle 3):
.menu-holder ul li:last-child {
border-right: 1px dotted white;
}
If I'm right, you only wanted to round the last element in the drop down menu and the second corner of the first one:
.menu-holder ul li ul li:first-of-type {
-webkit-border-radius: 0px 5px 0px 0px;
border-radius: 0px 5px 0px 0px;
}
.menu-holder ul li .submenu li:last-of-type {
-webkit-border-radius: 0px 0px 5px 5px;
border-radius: 0px 0px 5px 5px;
}
You can (and should) access the submenues like this:
.menu-holder ul li ul {
Instead of this:
.menu-holder ul li .submenu {
Cleaned and touched a couple of things more, and here is your code working. Tell me if you find any trouble. There's still room for improvement (readability and DRY to name some), but here it goes:
Final Demo
the sub menu is not displaying properly help me please
i want it in CSS and HTML
submenu should be like a list it should be displayed
one down another but it is displaying one after another in same line
after hover on main menu the submenu should be displayed
<style>
#navbar {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding:0;}
#navbar li
{
list-style: none;
float: left;
}
#navbar li a {
display: block;
padding: 3px 8px;
text-transform: uppercase;
text-decoration: none;
color: #999;
font-weight: bold; }
#navbar li a:hover {
color: #000; }
#navbar li ul {
display: none; }
#navbar li:hover ul, #navbar li.hover ul {
position: absolute;
display:list-item;
left: 0;
width: 100%;
margin: 0;
padding: 0; }
</style>
</head>
<body>
<ul id="navbar">
<li>Home</li>
<li>About Us
<ul>
<li>Subitem One</li>
<li>Second Subitem</li>
<li>thrid subitem</li>
</ul>
</li>
<li>Services</li>
<li>Products</li>
<li>Contact</li>
</ul>
add this in your css
#navbar li
{
list-style: none;
float: left;
position:relative;
}
here is jsFiddle file
Live demo
HI now used to this css and created drop down navi in pure css
Css
#navbar{
background:#0082c8;
position:relative;
margin-top:15px;
}
#navbar > li{
float:left;
margin:0 10px;
position:relative;
padding:14px 0;
}
#navbar li a, .subnavi li a{
color:white;
text-decoration:none;
display:inline-block;
line-height:29px;
padding:0 13px;
font-size:16px;
font-family:arial;
text-shadow: 0px 2px 2px #034e9f;
filter: dropshadow(color=#034e9f, offx=0, offy=2);
}
#navbar > li:hover > a, li:hover > a , #navbar li a.active{
background:#055c9f;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 0px 3px 3px 0px #042960;
-moz-box-shadow: inset 0px 3px 3px 0px #042960;
box-shadow: inset 0px 3px 3px 0px #042960;
border:1px solid #009ada;
color:#f7cf00;
line-height:27px;
padding:0 12px;
}
.subnavi{
position:absolute;
display:none;
top:51px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0px 0px 3px 1px #979395;
-moz-box-shadow: 0px 0px 3px 1px #979395;
box-shadow: 0px 0px 3px 1px #979395;
background:#0082c8;
border:1px solid #005890;
padding:10px 0;
white-space:nowrap;
}
#navbar li:hover .subnavi{
display:block;
}
#navbar .subnavi li{
margin:0;
}
#navbar .subnavi li a{
display:block;
font-size:13px;
padding:0 15px;
border-radius:0;
line-height:27px;
}
#navbar .subnavi li a:hover{
padding:0 15px;
border-radius:0;
border-left:0;
border-right:0;
line-height:25px;
}
#navbar:after{
content:'';
clear:both;
display:block;
overflow:hidden;
}
HTML
<ul id="navbar">
<li>About</li>
<li>Demo
<ul class="subnavi">
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
</ul>
</li>
<li>Demo</li>
</ul>
Live demo
Add this style for your submenus:
#navbar li ul li
{
float: none;
}