Dropdown content not showing up - css

When hovering over the "product" the content doesn't appear:
<nav>
<ul class="nav_links">
<li a href="#">Home</li>
<li class="dropdown" id="lol" a href="#">Products</li>
<ul class="dropdown-content">
<li a href="#">Health Care</li>
<li a href="#">Cosmetic</li>
<li a href="#">Misc.</li>
</ul>
<li a href="#">About Us</li>
<li a href="#">Register</li>
</ul>
</nav>
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a{
float: none;
color: black;
padding: 12px 6px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: black;
}
.dropdown:hover .dropdown-content{
display: block;
}
.dropdown:hover should be the case?
I don't know what's wrong with the code or class. What do you think I should try ?

.dropdown-content {
display: none;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a{
float: none;
color: black;
padding: 12px 6px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown:hover .dropdown-content{
display: block;
}
<nav>
<ul class="nav_links">
<li>Home</li>
<li class="dropdown" id="lol">
Products
<ul class="dropdown-content">
<li>Health Care</li>
<li>Cosmetic</li>
<li>Misc.</li>
</ul>
</li>
<li>About Us</li>
<li>Register</li>
</ul>
</nav>
Your code looks fine but you did not put an anchor tag inside the li tag. another thing I changed is in styling I removed absolute from dropdown-content, as it overlaps contents on each other.

Related

CSS: Menu with clickable logo inside

http://jsfiddle.net/2esybgmo/
html {
margin: 20px;
background: url("Images/background.png")center no-repeat fixed;
}
ul,
img {
margin: 0;
padding: 0;
vertical-align: middle;
}
.menu,
.dropdown-menu {
list-style-type: none;
background-color: white;
border-radius: 7px;
}
.menu li {
margin-left: -4px;
display: inline-block;
text-align: center;
border-right: 1px solid #eaeaea;
}
.menu li:first-child {
background-color: #4b424f;
border-top-left-radius: 7px;
border-bottom-left-radius: 7px;
}
.menu li a {
color: black;
display: block;
height: 100%;
padding: 17px 25px;
font-family: 'Montserrat', sans-serif;
font-size: 12px;
text-decoration: none;
margin: 0;
}
.menu li:hover .dropdown-menu {
display: block;
}
ul.dropdown-menu {
position: absolute;
border-top-right-radius: 0;
border-top-left-radius: 0;
border: none;
display: none;
}
ul.dropdown-menu li {
display: block;
text-align: left;
margin: 0;
border: none;
border-bottom: 1px solid #eaeaea;
}
ul.dropdown-menu li:last-child {
border: none;
}
ul.dropdown-menu li:first-child {
border-top: 1px solid #eaeaea;
background-color: White;
border-top-left-radius: 0;
}
<div id="header">
<ul class="menu">
<li><img src="Images/logo.png" alt="logo" height="28" width="117"">
</li>
<li>The Product
</li>
<li>Order Yours
</li>
<li>About Us
</li>
<li>
Support
<ul class="dropdown-menu">
<li>Read our FAQ
</li>
<li>Post a Support Ticket
</li>
<li>Orders & Shipping
</li>
</ul>
</li>
<li>Get in touch with us
</li>
</ul>
<p></p>
<div style="visibility: hidden;" class="flexslider">
<ul class="slides">
<li>
<img src="Images/background.png" alt="img1" />
</li>
<li>
<img src="Images/background.png" alt="img2" />
</li>
<li>
<img src="Images/background.png" alt="img3" />
</li>
</ul>
</div>
</div>
I would like the gray lines (border-right) in li elements fill the whole ul area (as well as the tags) like it used to do. After adding the image into the list there are a few pixels "missing" and I think the problem is because the image itself is a bit higher than the text inside tags. How to do it without changing image or text size?

CSS dropdown menu is 1 column on FF but 4 columns on Chrome etc

Need to know what's going on with my navigation. I'll post a screenshot. I have a drop down list using CSS and it displays fine on Chrome with 4 columns but on FireFox it is shown with 1 big long column. Help?
.nav{ background:#eaeadf; border-top:#eeeee5 solid 1px; margin:0px; box-shadow:0px -5px 5px #E7E9DA inset;}
.nav ul{ text-align: right; }
.nav ul li{ display: inline-block; }
.nav ul li span { color:#7c7c7c; font-size:16px; line-height:27px;}
.nav ul li a{ color:#7c7c7c; font-size:16px; padding:0px 10px; line-height:27px; text-transform:capitalize; margin: 0; display: inline-block; font-family:"Gill Sans", GillSans, Trebuchet, Calibri, sans-serif; letter-spacing: 1px; }
.nav ul li a:hover { color: #960530; }
.nav ul li:after { content:" | " ; color: #7c7c7c; font-size: 16px; line-height: 27px; }
.nav ul li.active:after { content: ""; }
.nav ul li:last-child a { padding-right: 0; }
.nav ul li:last-child:after { content: "";}
.nav ul li.active {
margin-left: -11px;
padding: 0 0 0 10px;
background: url(images/nav-active-left.png) left top no-repeat;
}
.nav ul li.active a {
color: #fff; position: relative;
background: url(images/nav-active-right.png) right top no-repeat; padding: 0 18px 0 12px;
}
.nav ul li.active a:after { top: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; }
.nav ul li.active a:after { border-top-color: #7a0427; border-width: 10px; left: 50%; margin-left: -10px; }
.nav ul li ul { background: #363838; text-align: center; }
.nav ul li.drop ul { display: none; }
/*.nav ul li.drop:hover ul, .nav ul li.drop ul:hover { display: block; }
*/
.extended-menu { background: #363838; padding: 20px; display: none;
-moz-box-shadow: inset 0 11px 10px -7px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: inset 0 11px 10px -7px rgba(0, 0, 0, 0.3);
box-shadow: inset 0 11px 10px -7px rgba(0, 0, 0, 0.3);
}
.extended-menu ul{ text-align: center; display: block; margin: 0 auto; max-width: 1130px; columns: 4; -webkit-columns: 4; column-rule: 2px inset #a9a9a9;
-webkit-column-rule: 2px inset #a9a9a9;
-moz-column-rule: 2px inset #a9a9a9;}
.extended-menu ul li { display: block; margin-bottom: 15px;}
.extended-menu ul li a { padding: 0 10px; margin: 0 10px; font-size:16px; color:#fff; line-height:1.1em !important;}
.extended-menu ul li a:hover { color: #960530; }
.extended-menu ul li:after{ content:" " ; color: #7c7c7c; font-size: 16px; line-height: 27px; }
.extended-menu ul li:last-child:after{ content:"" ; }
<div class="nav">
<div class="wrapper">
<ul>
<li class="drop">Future Students
<ul>
<li>About CU</li>
<li>Academics</li>
<li>Admissions</li>
<li>Apply Now</li>
<li>Athletics</li>
<li>CU Connect</li>
<li>Directory</li>
<li>Financial Services</li>
<li>Graduate Programs</li>
<li>Online & Professional Studies</li>
<li>Request Information</li>
<li>Student Development</li>
<li>Preview Day Registration</li>
<li>Student Right to Know</li>
</ul>
</li>
<li class="drop">Current Students
<ul>
<li>Academic Calendar</li>
<li>Business Office</li>
<li>Canvas Login</li>
<li>Career Services</li>
<li>Catalog, Forms, and Handbooks</li>
<li>Comment Form</li>
<li>CU Connect</li>
<li>Dean of Students</li>
<li>Dining Services</li>
<li>Directory</li>
<li>ePortal</li>
<li>Financial Services</li>
<li>Hire CU</li>
<li>Today # CU</li>
<li>Online & Professional Studies</li>
<li>Residence Life</li>
<li>Rudy Wellness Center</li>
<li>Community </li>
<li>Student Development</li>
<li>Student Policies</li>
<li>Vise Library</li>
<li>Student Email</li>
<li>Student Resources</li>
<li>Student Right to Know</li>
<li>Commencement 2015</li>
</ul>
</li>
<li class="drop">Faculty & Staff
<ul>
<li>Communications</li>
<li>Directory</li>
<li>Dining Services</li>
<li>ePortal</li>
<li>Faculty CAMS Login</li>
<li>Faculty & Staff Email</li>
<li>Intranet</li>
<li>IT Service Request</li>
<li>Rudy Wellness Center</li>
<li>Student Right to Know</li>
</ul>
</li>
<li class="drop">Alumni & Friends
<ul>
<li>Alumni & Friends</li>
<li>Alumni Benefits</li>
<li>Alumni Map</li>
<li>Alumni Update Form</li>
<li>CU Alumni Association</li>
<li>Downloads</li>
<li>Meet the Team</li>
<li>Newsletters</li>
<li>Social Networking</li>
<li>Upcoming Events</li>
<li>Request a Transcript</li>
<li>Sign Up For E-Newsletter</li>
</ul>
</li>
<li class="drop">THE NET.WORK™ Cumberland University Online
<ul>
<li>THE NET.WORK™ Cumberland University Online</li>
<li>Corporate Partners</li>
<li>Business Online</li>
<li>Criminal Justice Online</li>
<li>RN-BSN Online</li>
<li>MAE Online</li>
<li>MBA Online</li>
<li>FAQs</li>
</ul>
</li>
</ul>
<div class="cleer"></div>
</div>
<div class="extended-menu"></div>
<div class="cleer"></div>
</div>
Any help would be appreciated. Again- the code looks fine in Chrome but shows only 1 column in FireFox.

CSS Drop Down Menu Not working

i'm learning the basic of CSS and trying to create a dropdown menu, i tried creating a dropdown menu using plain CSS, but it's not working.
So far I tried this code:
CSS
<!-- because of the * default code it takes out all margin and padding or idententation -->
*{
margin: 0px;
padding: 0px;}
body
{
font-family: verdana;
background-color: ABC;
padding: 50px;
}
h1
{
text-align: center;
border-bottom: 2px solid #009;
margin-bottom: 50px;
}
/*rules for navigation menu */
/*============================================*/
ul#navmenu, ul.sub1
{
list-style-type: none;<!-- sets bullets to none -->
}
ul#navmenu li
{
outline: 1px solid red;
width: 125px;
text- align: center;
position: relative;
float: left;
margin-right: 4px;
}
ul#navmenu a
{
text-decoration: none;
display: block; <!-- this code makes the link a button instead pointing specifically on the link -->
width: 125px;
height: 25px;
line-height: 25px;
background-color: #FFF;
border: 1px solid #CCC;
border-radius: 5px;
}
ul#navmenu .sub1 li
{
}
ul#navmenu .sub1 a
{
margin-top: 0px;
}
ul#navmenu li:hover > a
{
background-color: #CFC; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu li:hover a: hover
{
background-color: #FF0; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu ul.sub1
{
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu li:hover .sub1
{
display: block;
}
HTML
<h1>Navigation Menu</h1>
<ul id="navmenu">
<li>Hyperlink 1</li>
<li>Hyperlink 2</li>
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
<li>Hyperlink 3</li>
<li>Hyperlink 4</li>
</ul>
</body>
</html>
The dropdown menu is not working, it's not hiding the sub menus, i don't know why.
Here is the picture screenshot using Internet Explorer:
IE
While using Google Chrome:
Chrome
I can't move on:( Any suggestion why dropdown menu is not working and why it's showing differently using other browsers?
Is there a way on how to code CSS dropdown menu where it will show the same on any browser? Thanks in advance.
JSFIDDLE
screen capture:
Use correct HTML buddy:
<ul id="navmenu">
<li>Hyperlink 1</li>
<li>Hyperlink 2
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
</li>
<li>Hyperlink 3</li>
<li>Hyperlink 4</li>
</ul>
And, add this CSS:
li ul{
display:none;
}
li:hover ul{
display:block;
}
Like this
please put ul in submenu
DEMO
HTML
<ul id="navmenu">
<li>Hyperlink 1</li>
<li>Hyperlink 2
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
</li>
<li>Hyperlink 3</li>
<li>Hyperlink 4</li>
</ul>
CSS
*{
margin: 0px;
padding: 0px;}
body
{
font-family: verdana;
background-color: ABC;
padding: 50px;
}
h1
{
text-align: center;
border-bottom: 2px solid #009;
margin-bottom: 50px;
}
/*rules for navigation menu */
/*============================================*/
ul#navmenu, ul.sub1
{
list-style-type: none;<!-- sets bullets to none -->
}
ul#navmenu li
{
width: 125px;
text- align: center;
position: relative;
float: left;
margin-right: 4px;
}
ul#navmenu a
{
text-decoration: none;
display: block; <!-- this code makes the link a button instead pointing specifically on the link -->
width: 125px;
height: 25px;
line-height: 25px;
background-color: #FFF;
border: 1px solid #CCC;
border-radius: 5px;
}
ul#navmenu .sub1 li
{
}
ul#navmenu .sub1 a
{
margin-top: 0px;
}
ul#navmenu li:hover > a
{
background-color: #CFC; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu li:hover a: hover
{
background-color: #FF0; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu ul.sub1
{
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu li:hover .sub1
{
display: block;
}
li ul{
display:none;
}
li:hover ul{
display:block;
}
DEMO2
DEMO3
You need to do three things..
1.Correction in HTML, Where there is 'li' tag with child 'ul'with id="sub1".You need to write it as
<li>Hyperlink 2
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
</li>
// there was a typo mistake.You close 'li' before the 'ul'. It should be closed in the end.
You need to display:none for sub1 menu.
li ul{
display:none;
}
Then show it when you hover that 'li'
li:hover ul{
display:block;
}
EDITED :Write this in style tag....
*{
margin: 0px;
padding: 0px;}
body
{
font-family: verdana;
background-color: ABC;
padding: 50px;
}
h1
{
text-align: center;
border-bottom: 2px solid #009;
margin-bottom: 50px;
}
/*rules for navigation menu */
/*============================================*/
ul
{
list-style-type: none;<!-- sets bullets to none -->
}
ul#navmenu li
{
width: 125px;
text- align: center;
float: left;
margin-right: 4px;
background-color: #FFF;
border: 1px solid #CCC;
border-radius: 5px;
}
ul#navmenu a
{
text-decoration: none;
display: block; <!-- this code makes the link a button instead pointing specifically on the link -->
width: 125px;
line-height: 25px;
}
ul#navmenu li:hover > a
{
background-color: #CFC;
}
li ul{
display:none;
left: -40px;
position: relative;
}
li:hover ul{
display:block;
}
ul#sub1 li:hover{
background-color:red;
}
TRY IT
Your html is wrong use, ul#sub1 should be child of <li>
<ul id="navmenu">
<li>Hyperlink 1</li>
<li>Hyperlink 2
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
</li>
<li>Hyperlink 3</li>
<li>Hyperlink 4</li>
</ul>
You have to put the ul tag in Sub Menu.
<ul id="navmenu">
<li>Hyperlink 1</li>
<li>Hyperlink 2
<ul id="sub1">
<li>Hyperlink 2.1</li>
<li>Hyperlink 2.2</li>
</ul>
</li>
<li>Hyperlink 3</li>
<li>Hyperlink 4</li>
</ul>
*{
margin: 0px;
padding: 0px;}
body
{
font-family: verdana;
background-color: ABC;
padding: 50px;
}
h1
{
text-align: center;
border-bottom: 2px solid #009;
margin-bottom: 50px;
}
/*rules for navigation menu */
/*============================================*/
ul#navmenu, ul.sub1
{
list-style-type: none;<!-- sets bullets to none -->
}
ul#navmenu li
{
width: 125px;
text- align: center;
position: relative;
float: left;
margin-right: 4px;
}
ul#navmenu a
{
text-decoration: none;
display: block; <!-- this code makes the link a button instead pointing specifically on the link -->
width: 125px;
height: 25px;
line-height: 25px;
background-color: #FFF;
border: 1px solid #CCC;
border-radius: 5px;
}
ul#navmenu .sub1 li
{
}
ul#navmenu .sub1 a
{
margin-top: 0px;
}
ul#navmenu li:hover > a
{
background-color: #CFC; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu li:hover a: hover
{
background-color: #FF0; <!-- sets all link color when hovering to yellow -->
}
ul#navmenu ul.sub1
{
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu li:hover .sub1
{
display: block;
}
li ul{
display:none;
}
li:hover ul{
display:block;
}
Try This it will surely work...

How do I stop CSS inheritance?

please take a look at the CSS below the subMenu li keep inheriting all the stylings from the MainMenu even when I gave it it own ones!
For example there are padding on the MainMenu, the subMenu applies them to itself as well even if I gave it it own padding it won't use them and it will still uses the ones that are on the MainMenu, Please help, thanks in advance...
#headerMenu{
float: right;
}
/*Main Menu*/
#MainMenu li{
padding: 8px 12px 5px 12px;
position: relative;
list-style: none;
float: left;
}
#MainMenu a{
color: #757575;
}
#MainMenu a:hover{
color: #7FA0BA;
}
#MainMenu a.active{
color: #305067;
}
#MainMenu li a.getStartedButton{
color: #A3C182;
}
#MainMenu li a.getStartedButton:hover{
color: #7FA0BA;
}
/*SubMenu*/
ul.subMenu{
background-color: #FFFFFF;
border: 1px solid black;
position: absolute;
top: 49px;
-webkit-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
-moz-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
}
.subMenu li{
background-color: orange;
width: 95px;
padding: 2px 2px 2px 3px;
position: relative;
text-align: left;
list-style: none;
}
.subMenu li a{
background-color: black;
}
/*Tablets & Smart Phones (Must Be Hidden From Widescreen)*/
.SecondHeader-button,#SecondHeader{
display: none;
}
/*////////////////////////////*/
The HTML is as follows:
<header>
<div id="wrapperHeader">
<div class="scrollable" id="headerContent">
<section class="headerLogo">
<img id="logoImage" src="assets/elements/logo.png" alt="LOAI Design Studio Logo"/>
</section>
<section id="headerMenu">
<nav>
<ul id="MainMenu">
<li><a class="active" href="index.html">Home</a></li>
<li><a class="SubMenu" href="#">Portfolio</a>
<ul class="subMenu">
<li>Web Design</li>
<li>Visual Identity</li>
<li>Photography</li>
</ul>
</li>
<li>Testimonials</li>
<li>About Me</li>
<li>Get In Touch</li>
<li><a class="getStartedButton" href="get-started.html">Get Started</a></li>
</ul>
</nav>
</section>
</div>
</div>
</header>
According to CSS Specificity Rules
#MainMenu li
Is more specific than
.subMenu li
And that is why the latter (.subMenu li) doesn't override the former (#MainMenu li).
Try:
#mainMenu .subMenu li
And read on http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

How do you make the area of hover in css larger

I have a list in html that I am formatting as a drop down menu in CSS, however, when I hover over, only the first half of the text is responding, as opposed to the entire length of it, and I can't figure out which property to change in order to make this hover area longer.
thanks!
code:
#navbar {
position: relative;
margin: 10px;
margin-left: -27px;
/*height: 13px; */
float: left;
}
#navbar li {
list-style: none;
float: left;
}
#navbar li a {
display: block;
padding: 3px 8px;
background-color: #00AA63;
color: #fff;
text-decoration: none;
}
#navbar li ul {
color: #fff;
display: none;
width: 10em;
}
#navbar li:hover ul {
display: block;
position: absolute;
margin: 0;
padding: 0;
/*width: 200%;*/
}
#navbar li:hover li {
float: none;
/*width: 200%;*/
}
#navbar li:hover li a {
background-color: #00AA63;
color: #fff;
border-bottom: 1px solid #fff;
color: #fff;
}
#navbar li li a:hover {
color: #fff;
background-color: #33BB96;
}
Jquery stuff:
document.getElementById("menu").innerHTML += '<ul id="navbar">'
+ '<li>other electives'
+ '<ul id="navbar">'
+ '<li>Subitem One</li>'
+ '<li>Second Subitem</li>'
+ '<li>Numero Tres</li></ul>'
+ '</li>'
edit:
implementation:
http://jsfiddle.net/CLVwv/1/
The problem is because you have set negative margin on each ul.
Just remove the padding from .navbar and reduce the margin to get the spacing you desire.
.navbar {
position: relative;
margin: 10px 1px;
/*height: 13px; */
float: left;
padding-left: 0px;
}
You can also reduce your CSS by removing the ID tags and using a .navbar class, this will also make your code more flexible as you don't have to add any new CSS each time you wish to add an item to the menu:
.navbar {
position: relative;
margin: 10px 1px;
/*height: 13px; */
float: left;
padding-left: 0px;
}
.navbar li {
list-style: none;
overflow: hidden;
}
.navbar li a {
display: block;
padding: 3px 8px;
background-color: #00AA63;
color: #fff;
text-decoration: none;
}
.navbar li ul {
color: #fff;
display: none;
width: 10em;
}
.navbar li:hover ul {
display: block;
position: absolute;
margin: 0;
padding: 0;
/*width: 200%;*/
}
.navbar li:hover li {
float: none;
/*width: 200%;*/
}
.navbar li:hover li a {
background-color: #00AA63;
color: #fff;
border-bottom: 1px solid #fff;
color: #fff;
}
.navbar li li a:hover {
color: #fff;
background-color: #33BB96;
}
HTML:
<ul class="navbar">
<li>other electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
</ul>
<ul class="navbar">
<li>other electivesother electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
</ul>
<ul class="navbar">
<li>other electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
</ul>
See http://jsfiddle.net/georeith/CLVwv/2/ for a working solution.
The reason that's happening is because of the negative margins you have on the ul's. ul#navbar2 is covering #navbar1 and #navbar3 is covering #navbar2.
Is there a reason you need three seperate ul's? If you use the following html the issue is resolved:
<ul id="navbar">
<li>other electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
<li>other electivesother electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
<li>other electives
<ul class="navbar">
<li>Subitem One</li>
<li>Second Subitem</li>
<li>Numero Tres</li></ul>
</li>
</ul>
I also added a 3px padding to #navbar li:
#navbar li {
list-style: none;
float: left;
padding-right: 3px;
}
See the fiddle: http://jsfiddle.net/2wFjA/1/

Resources