CSS drop-down submenu text issue - html

Ok. So I have started to build a website, and I have tried to build a dropdown menu using css and html. The hover function for the submenu works. My only issue is, when you mouse over the menu to get to the submenu, I can't figure out how to change the font to black so it is visible.Here is a page where I am testing the code: http://mcbtaytest.zymichost.com/
Here is my code:
CSS:
body {margin:0;
padding:0;
background:#000000
}
.image{
border: none;
border:0px;
margin:0px;
padding:0px;
z-index: -1;
}
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
z-index:2;
}
.menu ul{
background:#FFFFFF;
height:50px;
list-style:none;
margin:0;
padding:0;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
-moz-box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
}
.menu li{
float:left;
padding:0px 0px 0px 15px;
}
.menu li a{
color:#000000;
display:block;
font-weight:normal;
line-height:50px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover{
background:#000000;
color:#FFFFFF;
text-decoration:none;
-webkit-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
-moz-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
}
.menu ul li:hover a{
background:#000000;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul{
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:200px;
z-index:200;
}
.menu li:hover ul{
display:block;
}
.menu li li {
display:block;
float:none;
margin:0px;
padding:0px;
width:200px;
background:#FFFFFF;
/*this is where the rounded corners for the dropdown disappears*/
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:50px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a{
border:0px;
color:#ffffff;
text-decoration:none;
background:#000000;
-webkit-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
-moz-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
}
HTML:
<div class="image">
<img src="/Resources/img/Header.png" width=100% style={margin:0;padding:0;}/></img>
</div>
<div class="menu">
<ul>
<li><a href="#" >Home</a></li>
<li>
About
<ul>
<li>Company Info</li>
</ul>
</div>
I for some reason can't figure out how to solve this.

Edited:
Change the following line
.menu ul li:hover a
with this line;
.menu ul li:hover > a
It is more specific now.
SEE DEMO

I made some changes to your html (it was broken, and some elements where redundant), and your css (removed some selectors and rewrote others).
Is this something like what you were going for?

add color:#000 on .menu li:hover li a:
.menu li:hover li a{
background:none;
color:#000;
}

Related

I want to put hover on background and text color at a time

I need to put hover at a time on background and text color.. please tell me how could i do this...When i hover, i want to change the text color and background .. which property should i apply
here is my code and image.
http://s29.postimg.org/i0ivezr07/image.jpg
.menu{
height:65px;
width:100%;
background-color:#cccc99;
box-shadow:0px 1px 2px #000000;
-moz-box-shadow: 0px 1px 2px #000000;
-webkit-box-shadow: 0px 1px 2px #000000;
}
.logo{
float:left;
margin: 5px 6px;
position:relative;
}
.menu-text{
float:right;
width:570px;
margin: -8px 0px;
}
.menu-text ul{
list-style:none;
}
.menu-text ul li{
float:left;
height:60px;
width:94px;
line-height: 60px;
border-right:1px solid #e6e6e6;
text-align: center;
font-size:16px;
font-weight:bold;
text-shadow: 0px 1px 2px #757575;
}
.menu-text ul li:hover{
}
.menu-text ul li:last-child{
border:none;
}
.menu-text ul li a{
text-decoration:none;
color: #333333;
}
.menu-text ul li a:hover{
}
.menu-text ul li a:hover ul li:hover{
background-color:#FFF;
color:#FFF;
}
.menu-belt{
width:100%;
height:10px;
background:#cccc99;
box-shadow:0px -1px 2px #a9a9a9;
-webkit-box-shadow: 0px -1px 2px #a9a9a9;
-moz-box-shadow: 0px -1px 2px #a9a9a9;
float:left;
margin: -13px 0;
}
<div class="menu">
<div class="logo">
<a href="#">
<img src="images/logo.png" alt="logo" />
</a>
</div> <!--/logo-->
<div class="menu-text">
<ul>
<li> Home</li>
<li> Operator</li>
<li> Drive </li>
<li> Booking </li>
<li> Rider </li>
<li> Logout </li>
</ul>
</div> <!--/menu-text-->
<div class="menu-belt">
</div> <!--menu-belt-->
</div> <!--/menu-->
Just add it on the :hover
.menu-text ul li a:hover{
color: red;
background-color: green;
}
:hover is the css used when the mouse if hovering on the element.
Use :hover property for CSS
Syntax:
classname:hover{ property1:value; property2:value;)
.menu{
height:65px;
width:100%;
background-color:#cccc99;
box-shadow:0px 1px 2px #000000;
-moz-box-shadow: 0px 1px 2px #000000;
-webkit-box-shadow: 0px 1px 2px #000000;
}
.item1
{
display:block;
border:1px solid #000;
width:60px;
padding:10px;
}
.item1:hover
{
background:lightgreen;
color:white;
}
<div class="menu">
<span class="item1">MENU</span>
</div>
CSS Syntax
classname:hover { color:green; background:red;}
You also have to make the a-tag fill out the whole surrounding li element by adding display:block;
.menu{
height:65px;
width:100%;
background-color:#cccc99;
box-shadow:0px 1px 2px #000000;
-moz-box-shadow: 0px 1px 2px #000000;
-webkit-box-shadow: 0px 1px 2px #000000;
}
.logo{
float:left;
margin: 5px 6px;
position:relative;
}
.menu-text{
float:right;
width:570px;
margin: -8px 0px;
}
.menu-text ul{
list-style:none;
}
.menu-text ul li{
float:left;
height:60px;
width:94px;
line-height: 60px;
border-right:1px solid #e6e6e6;
text-align: center;
font-size:16px;
font-weight:bold;
text-shadow: 0px 1px 2px #757575;
}
.menu-text ul li:hover{
}
.menu-text ul li:last-child{
border:none;
}
.menu-text ul li a{
text-decoration:none;
color: #333333;
display: block; //this makes the a tag fill out the whole surrounding li
}
.menu-text ul li a:hover{
background-color: red; //add this of course....
color: green;
}
.menu-text ul li a:hover ul li:hover{
background-color:#FFF;
color:#FFF;
}
.menu-belt{
width:100%;
height:10px;
background:#cccc99;
box-shadow:0px -1px 2px #a9a9a9;
-webkit-box-shadow: 0px -1px 2px #a9a9a9;
-moz-box-shadow: 0px -1px 2px #a9a9a9;
float:left;
margin: -13px 0;
}
<div class="menu">
<div class="logo">
<a href="#">
<img src="images/logo.png" alt="logo" />
</a>
</div> <!--/logo-->
<div class="menu-text">
<ul>
<li> Home</li>
<li> Operator</li>
<li> Drive </li>
<li> Booking </li>
<li> Rider </li>
<li> Logout </li>
</ul>
</div> <!--/menu-text-->
<div class="menu-belt">
</div> <!--menu-belt-->
</div> <!--/menu-->

footer locks in position

I have modified App footer to stay at the bottom of the page if the page content is little.
So it wouldn't left free space afterwards. It works just great.
But now I discovered that in pages where content is much more than it fits in current window, footer has stayed at the same place, but the content expands in background of footer.
It looks like
this
My CSS for footer.
#footerCntr {
position:absolute;
bottom:0;
width:100%;
overflow: hidden;
background:#e7e7e7;
border-top:3px solid #b7b7b7;
margin:11px 0px 0px 0px;
}
.footerBox{
width:780px;
margin: 0px auto;
padding:11px 0px 14px 0px;
}
.footerBoxLeft{
float:left;
width:176px;
padding:8px 0px 9px 26px;
background:url(bordery.gif) right top repeat-y;
}
.footerBoxLeft img{
float:left;
margin:0px 0px 0px 2px;
}
.footerBoxRight{
float:right;
width:575px;
padding:0px 0px 10px 0px;
}
.footerlink ul{
padding:7px 0px 5px 0px;
}
.footerlink ul li{
list-style:none;
padding:0px 10px 0px 10px;
display:inline;
background:url(devider.gif) 0px 3px no-repeat;
}
.footerlink ul li a{
font:10px Tahoma , Arial, Helvetica, sans-serif;
color:#535353;
text-decoration:none;
padding:0px 0px 0px 0px;
}
.footerlink ul li a:hover{
text-decoration:underline;
}
.copyright{
color:#535353; padding:0px 0px 0px 10px;
}
.copyright a{
font:10px Tahoma , Arial, Helvetica, sans-serif;
color:#535353;
text-decoration:none;
padding:5px 0px 0px 0px;
}
.copyright a:hover{
text-decoration:underline;
}
Link to my app problem.
It could be problem with content CSS formating ?
here

drop-down css menu behind the actual menu (z-index)

I'm having problem with submenu hiding behind the next line of menu.
vs
I've searched many topics and questions and basically everyone's saying that I need to add z-index > 100 to my sub-menu. I tried that everywhere, where sub-menu's present but nothing worked.
Do you have any idea how to make it work as it should?
Here's my code:
#header #nav{
float:right;
margin:0px;
position:relative;
z-index:100;
}
#header #nav > li {
display:inline-block;
margin:0;
position:relative;
z-index:100;
}
#header #nav > li > a{
color:#727272;
border:none;
background:none;
font-size:11px;
font-weight:700;
height:60px;
line-height:59px;
display:block;
padding:0 15px;
background:none center bottom;
position:relative;
}
#header #nav > li > a:hover{
color: #0073fe;
}
#nav li ul.sub-menu{
width:210px;
background:#fff;
position:absolute;
border:1px solid #ececec;
border-top:2px solid #0073fe;
margin:0;
top:96%;
padding:0 15px;
display:none;
-webkit-box-shadow: 0px 2px 50px 10px rgba(0, 0, 0, 0.05);
box-shadow: 0px 2px 50px 10px rgba(0, 0, 0, 0.05);
margin-top:2px;
}
#nav li ul.sub-menu > span{
position:absolute;
top:-6px;
left:30px;
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #0073fe;
}
#nav li ul.sub-menu > li{
margin:0;
width:100%;
display:block;
}
#nav li ul li a{
font-size:11px;
font-weight:700;
display:block;
padding:7px 0px;
color:#727272;
border:none;
border-bottom:1px solid #ececec;
}
#nav li ul li a:hover{
color: #0073fe;
}
#nav li ul li:last-child a{
border-bottom:none !important;
}
#nav li ul li ul.sub-menu{
margin-left: 190px !important;
margin-top: -35px !important;
}
.slogan{
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
font-size:34px;
line-height:35px;
text-align:center;
font-weight:300;
letter-spacing: -0.01em;
color:#000;
padding:0px 30px 30px;
}
So you want : submenu > menu; which means: #nav li ul.sub-menu > #header/#nav
The problem is that you set up your menu to a high z-index and not your submenu (and results in: submenu < menu).
z-index defines a "set a layers" where your element would be, if it's set higher than an other one, then it will appear on top of it.
You need to delete the z-index for #header #nav and #header #nav>li and instead put a high z-index to #nav li ul.sub-menu.
#nav li ul.sub-menu {
z-index: 50; //It doesn't have to be a hundred, 50 should do, or even 5...
}

Adding drop down effect on css menu

*I exhaustedly searched this site for an answer before posting a question, I attempted multiple solutions and nothing worked to my exact codes. While you may find duplicate questions on this site. I don't consider it to be a duplicate unless the coding is EXACTLY the same as well as the solutions. Nothing on this site worked for my exact coding therefore I needed to post my exact code for help. *
I have a menu that looks like the one below. and the drop down on it. Right now the nested ul just simply spreads throughout the page. it needs to show up in a nice drop down section under administration. I have tried searching for this and asking my colleagues none of them have done it before. I have created a jsFiddle here: http://jsfiddle.net/z3Lpm/
<div id="menu">
<ul>
<li>Home</li>
<li>Administration
<ul>
<li>Products</li>
</ul>
</li>
</ul>
</div>
(not my full menu but you get the point.)
and then my css:
#menu{
width: 100%;
border: 1px solid #000;
height: 50px;
background-color:#181818;
font-family: Helvetica, sans-serif;
font-size: 13px;
}
#menu ul{
margin-top: 20px;
}
#menu ul li{
list-style-type: none;
display: inline;
margin-left: 50px;
}
#menu ul li a:link{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
padding-top: 40px;
padding-bottom: 40px;
padding-left: 20px;
padding-right: 20px;
}
#menu ul li a:visited{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
}
#menu ul li a:hover{
color: #FFF;
background-color: #81B101;
-webkit-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
-moz-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
}
Here, I didn't change up the colors or anything because I don't know what you are doing with them. Let me know if this works for you.
http://jsfiddle.net/talymo/LDNpG/
#menu{
background-color:#181818;
font-family: Helvetica, sans-serif;
font-size: 13px;
height:50px;
}
#menu ul{
list-style:none;
padding-top:15px;
}
#menu ul li{
padding:0px 20px;
width:auto;
float:left;
position:relative;
}
#menu ul li:hover > ul{
display:block;
}
#menu ul li a{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
padding-top: 40px;
padding-bottom: 40px;
padding-left: 20px;
padding-right: 20px;
}
#menu ul li a:hover{
color: #FFF;
background-color: #81B101;
-webkit-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
-moz-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
}
#menu ul li ul{
overflow:hidden;
padding:0;
margin:0;
display:none;
position:absolute;
top:20px;
}

Drop Down navi is not working ie 7?

I have make a new dropdown navi in css .
Chrome, firefox, safari is running fine but IE7 is not show of drop-down .
css
.cl{clear:both;}
#navi{
background:#0082c8;
position:relative;
margin-top:15px;
}
#navi:after{
position:absolute;
content:"";
left:0;
right:0;
top:0;
height:5px;
background:#00a7ff;
border-top:1px solid #0285cb;
border-bottom:2px solid #0068a6;
box-shadow:inset 0 0 0 1px #26c6f8;
}
#navi:before{
position:absolute;
content:"";
left:0;
right:0;
bottom:0;
height:5px;
background:#00a7ff;
border-top:1px solid #0285cb;
border-bottom:2px solid #0068a6;
box-shadow:inset 0 0 0 1px #26c6f8;
}
#navi > li{
float:left;
margin:0 10px;
position:relative;
padding:14px 0;
}
#navi 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);
}
#navi > li:hover > a, li:hover > a , #navi 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;
}
#navi li:hover .subnavi{
display:block;
}
#navi .subnavi li{
margin:0;
}
#navi .subnavi li a{
display:block;
font-size:13px;
padding:0 15px;
border-radius:0;
line-height:27px;
}
#navi .subnavi li a:hover{
padding:0 15px;
border-radius:0;
border-left:0;
border-right:0;
line-height:25px;
}
​
HTML
<ul id="navi">
<li>About</li>
<li>Services
<ul class="subnavi">
<li>Web Development</li>
<li>WordPress</li>
<li>Graphic Design</li>
<li>Icon Design</li>
<li>Motion Graphics</li>
</ul>
</li>
<li>Works</li>
<div class="cl"></div>
</ul>​
Link here http://jsfiddle.net/rohitazad/3qPbE/11/
Hi This is not the answer but its just a thought from my side.
Insted of using float: left; you can try with display:inline-block; and add hack for IE:
Zoom:1;
*display:inline;
Try just this. If its working Try next time onwards Disply:inline-block;