my drop down menu disappears before i can click on it - css

the drop down menu disappears before you can click on a link. i thought it was a confict with the slider but even if i get rid of it i still have the issue. the site is tourismreddeer.com
here is the html:
<ul class="headerNav">
<a class="btnHome" href="/"><span>Home</span></a>
<li>About Red Deer<img src="/images/link_photo_about.png" width="81" height="81" />
</li>
<li>Events & Attractions<img src="/images/link_photo_events.png" width="81" height="81" />
<ul class="sub-menu sub-events">
<li>Red Deer & Area Events</li>
<li>Business Listings</li>
<li>Mud Hero</li>
</ul>
</li>
<li>Plan Your Trip<img src="/images/link_photo_holiday.png" width="81" height="81" /></li>
<li>Places to Stay<img src="/images/link_photo_accommodations.png" width="81" height="81" /></li>
<li>Meetings & Sports<img src="/images/link_photo_sports.png" width="81" height="81" /></li>
and this is the css:
.btnHome {
position: absolute;
top: 30px !important;
left: 0px;
width: 200px;
height: 115px;
background-image: url(../images/spacer.gif);
}
.header {
position: relative;
top: 0px;
width: 986px;
height: 148px;
background-repeat: no-repeat;
background-position: 0px 95px;
}
.header ul {
font-family: 'PT Sans Narrow', arial, serif;
color: #fff;
font-size: 17px;
list-style: none;
margin: 0px;
padding: 0px;
}
.header a {
color: #fff;
}
.header ul a {
position: absolute;
top: 111px;
}
.linkGreen {
left: 242px;
}
.linkBlue {
left: 395px;
}
.linkPurple {
left: 545px;
}
.linkBrown {
left: 695px;
}
.linkYellow {
left: 843px;
}
.header ul a img {
position: absolute;
top: -78px;
left: 14px;
}
.headerLinks {
position: absolute;
top: 0px;
right: 0px;
font-family: 'PT Sans Narrow', arial, serif;
color: #fff;
font-size: 14px;
width: 320px;
height: 28px;
padding: 7px 0px 0px 0px;
}
.headerLinks a {
padding: 0px 4px 0px 4px;
}
.headerLinkConsumer {
position: absolute;
top: 0px;
right: 83px;
width: 86px;
height: 34px;
background-image: url(../images/link_header_consumer_lo.png);
background-repeat: no-repeat;
}
.headerLinkConsumer:hover, .headerLinkConsumer.current {
background-image: url(../images/link_header_consumer.png);
}
.headerLinkIndustry {
position: absolute;
top: 0px;
right: -3px;
width: 86px;
height: 34px;
background-image: url(../images/link_header_industry_lo.png);
background-repeat: no-repeat;
}
.headerLinkIndustry:hover, .headerLinkIndustry.current {
background-image: url(../images/link_header_industry.png);
}
.headerShadow {
position: absolute;
right: 0px;
top: 95px;
}
.headerLogo {
position: absolute;
left: 0px;
top: 27px;
}
.headerLogoSide {
position: absolute;
left: -24px;
top: 43px;
}
ul.headerNav ul {display: none;}
ul.headerNav li:hover > ul {
display: block;}
ul.headerNav li a:hover > ul li {
display: block;}
ul.headerNav li:hover > ul.sub-events {
margin: 148px 0 0 375px;}
.headerNav .sub-menu {
position:absolute;
z-index:12000;
display:none;
background:#999999 !important;
padding:5px 15px;
-webkit-box-shadow:1px 1px 2px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow:1px 1px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow:1px 1px 2px 0px rgba(0, 0, 0, 0.2);
-webkit-border-radius:0px 0px 3px 3px;
-moz-border-radius:0px 0px 3px 3px;
border-radius:0px 0px 3px 3px;
border-top:3px solid #555555;
}
.headerNav .sub-menu li {
display: block !important;
margin: 0 !important;
padding: 0 !important;
height: auto !important;
border-bottom: 1px solid #a5a5a5;
border-left: none !important;
}
.headerNav .sub-menu li a{
height: auto !important;
line-height: 1 !important;
padding:10px 0 !important;
}
html body .headerNav .sub-menu li a,
html body .headerNav .sub-menu li .sub-menu li a,
html body .headerNav .sub-menu li .sub-menu li .sub-menu li a {
border: none !important;
display: block !important;
width: 160px;
margin: 0 !important;
padding: 8px 0px !important;
color: #dedede;
line-height: normal;
font-weight: normal !important;
height: auto;
background: none !important;
position:inherit;
}
.headerNav .sub-menu li a:hover,
.headerNav .sub-menu li .sub-menu li a:hover,
.headerNav .sub-menu li.current-menu-item a,
.headerNav .sub-menu li.current-menu-item a:hover,
.headerNav .sub-menu li.current_page_item a,
.headerNav .sub-menu li.current_page_item a:hover {
color: #ffffff !important;
font-weight: normal;
}
.headerNav .sub-menu li:last-child{
border: none;
}
.headerNav .sub-menu li ul {
top: -1px !important;
left: 178px !important;
border-top: none;
-webkit-border-radius:3px;
-moz-border-radius:3px;
border-radius:3px;
}

You have some pretty weird stuff going on inside your CSS. The actual menu bar is sitting up above the web page and the text from them is hanging down using absolute positioning and offsets. I'm not going to bang on about how you should redo a lot of this CSS because you probably know that and you came here for a solution. Here's what I managed:
It's not perfect but it's a tough piece to work with:
Change this selector like so:
.header ul a {
position: absolute;
top: 111px;
padding-bottom:20px; /* <-- this is the new bit */
}
This will mean your link text will hold its 'hover' status until the cursor crosses over onto the menu, kinda using the padding as a "bridge".
Again, this is a quick and dirty fix and I strongly suggest a larger-scale re-work but if you have deadlines, such is life.

Related

Equal Spacing in Navbar

I've made a "Sticky Navbar using CSS and HTML5 and I have 4 links to place on the navbar but I can't get them to space themselves Equally now before you say this is a duplicate and all, but first of all none of the solutions worked for me and second, I have a logo in the middle of the navbar... Some help Please!heres my website: catsonfire.tk
<style>
article {
margin: auto;
height:auto;
padding-bottom:10px;
}
header {
margin: auto;
width: 100%;
position: relative;
top: 16px;
height: 60px;
}
footer {
background-color: wheat;
align-content: center;
margin: auto;
width:100%
}
nav {
position: relative;
width: 100%;
}
#header_container ul {
margin: 0;
padding: 0px;
list-style-type: none;
text-align: center;
}
#main {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
#header_container ul li {
display: inline;
width: 25%;
margin:0;
padding:0;
}
#header_container ul li a {
text-decoration: none;
padding: 39px;
color: #fff;
padding: 12px 0 13px 0;
}
#header_container ul li a:hover {
color: #000;
background-color: rgba(0, 0, 0, 0.7);
box-shadow: 1px 1px 1px inset;
-moz-box-shadow: 1px 1px 1px inset;
-webkit-box-shadow: 1px 1px 1px inset;
}
#big {
background: rgba(0, 0, 0, 0.5);
top: 0px;
left: 0px;
right: 0px;
margin: 0px;
width: 100%;
position: absolute;
height: 105px;
}
#header_container {
left: 0;
position: fixed;
width: 100%;
top: 0;
z-index:1000;
height:150px
}
#header {
line-height: 60px;
margin: 0 auto;
}
</style>
Home
About
Your site shows two links, but some thoughts:
#big ul{
display:block;
}
#big li {
display:block;
width:25%;
float:left;
text-align:center;
}
#big li a{
display:inline-block;
}
Makes the li element 1/4th of the width of its parent ul, then centers each a element in those. Add your styles as you want it to look.

CSS3 dropdown menu not working anymore

Ive been making a website with a CSS3 menu. However during the validating process to check if i made no mistakes i broke my CSS3 menu. The menu itself works but theres no drop down menu when hovering "Categorieen" like it did before.
Heres the HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
<title>Website Ronald</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="style.css"/>
<style type="text/css">
html {
background: url(images/image2.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
</style>
</head>
<body style="margin:0px;padding:0px;overflow:hidden">
<ul id="menu">
<li>Home</li>
<li>Categorieën</li>
<ul>
<li>Vliegvelden</li>
<li>Landschappen</li>
<li>Auto`s</li>
</ul>
<li>Over</li>
</ul>
<div align="center">
<iframe src="home.html" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden; height:90%;width:75%;position:absolute;top:60px;left:160px;right:0px;bottom:10px" width="75%" height="90%" name="frame_a" marginheight="5" frameborder="0"></iframe>
</div>
</body>
</html>
And this is the CSS im using:
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu {
width: 960px;
margin: 10px auto;
border: 1px solid #222;
background-color: #111;
background-image: linear-gradient(#444, #111);
border-radius: 6px;
box-shadow: 0 1px 1px #777;
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu:after {
clear: both;
}
#menu {
zoom:1;
}
#menu li {
float: left;
border-right: 1px solid #222;
box-shadow: 1px 0 0 #444;
position: relative;
}
#menu a {
float: left;
padding: 12px 30px;
color: #999;
text-transform: uppercase;
font: bold 12px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover { /* IE6 only */
color: #fafafa;
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
border-radius: 3px;
transition: all .2s ease-in-out;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
_margin: 0; /*IE6 only*/
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
float: none;
display: block;
border: 0;
_line-height: 0; /*IE6 only*/
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
box-shadow: none;
}
#menu ul a {
padding: 10px;
width: 130px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a:hover {
background-color: #0186ba;
background-image: linear-gradient(#04acec, #0186ba);
}
#menu ul li:first-child > a {
border-radius: 3px 3px 0 0;
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px;
top: -6px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #444;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50%;
margin-top: -6px;
border-left: 0;
border-bottom: 6px solid transparent;
border-top: 6px solid transparent;
border-right: 6px solid #3b3b3b;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #04acec;
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #0299d3;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
border-radius: 0 0 3px 3px;
}
Since your submenu must appear while hovering "Categorieen" and since your css to make it visible look like #menu li:hover > ul
The <ul> element containing your submenu must be inside the <li> representing "Categorieen"
So instead of
<li>
Categorieën
</li>
<ul>
<li>Vliegvelden</li>
<li>Landschappen</li>
<li>Auto`s</li>
</ul>
You should have
<li>
Categorieën
<ul>
<li>Vliegvelden</li>
<li>Landschappen</li>
<li>Auto`s</li>
</ul>
</li>
Here is the jsfiddle representing your corrected menu

Drop down menu width issue [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Despite of many efforts, I am unable to make the drop down menu of the same width as of the parent. Please help me out. Fiddle here
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu {
width: 958px;
/*margin: 60px auto;*/
border: 1px solid #222;
background-color: #111;
background-image: linear-gradient(#444, #111);
box-shadow: 0 1px 1px #777;
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu:after {
clear: both;
}
#menu {
zoom:1;
}
#menu li {
float: left;
border-right: 1px solid #222;
box-shadow: 1px 0 0 #444;
position: relative;
}
#menu a {
float: left;
padding: 11px 40px;
color: #999;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover { /* IE6 only */
color: #fafafa;
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1000000;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
transition: all .2s ease-in-out;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
_margin: 0; /*IE6 only*/
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
float: none;
display: block;
border: 0;
_line-height: 0; /*IE6 only*/
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
box-shadow: none;
}
#menu ul a {
padding: 10px;
width: 130px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a:hover {
background-color: #000000;
}
#menu ul li:first-child > a {
/*border-radius: 3px 3px 0 0;*/
padding: 11px 13px;
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px;
top: -6px;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50%;
margin-top: -6px;
border-left: 0;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #000;
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #000;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
/*border-radius: 0 0 3px 3px*/;
padding: 11px 20px;
}
​
HTML:
<ul id="menu">
<li>About </li>
<li>Programmes
<ul>
<li>Undergraduate</li>
<li>Postgraduate</li>
</ul>
</li>
<li>Academics</li>
<li>Research</li>
<li>Facilities</li>
<li></li>
</ul>
​
In the dropdown menu ul element add "right: 0" (or -1px in your case to take into account the borders):
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
right: -1px /* <-- add this */
z-index: 1000000;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
transition: all .2s ease-in-out;
}
Then remove the width property in the a element:
#menu ul a {
padding: 10px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
This will work independently of the menu container width.
working fiddle http://jsfiddle.net/chopsticks/XLxJk/4/
#menu ul a {
padding: 10px;
width: 150px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul li:first-child > a {
padding: 11px 20px;
}
DEMO
So by positioning your dropdown menu absolutely you are removing it from the flow. This causes it to no longer size to the width of it's parent element. You'll need to explicitly set the width, set the width explicitly via js (if you want the menu items to size based on the text they contain) or figure out how to position it differently so it inherits the width.
How about this ?
Just set the width to 100% in the #menu ul, and you have a dropdown of the same size.
http://jsfiddle.net/XLxJk/3/

CSS drop-down menu

SEE LIVE MENU HERE.
I am trying to figure out why the drop-down disappears after you attempt to rollover it. Can someone see the problem in my code? Thank you.
HERE IS MY HTML MENU
<div id="menu">
<ul>
<li><span>Needs Assessment</span> </li>
<li><span>Knowledge Acquisition</span>
<ul>
<li>Administer Knowledge<br>Pre-Test</li>
<li>Assign Asthma<br>Article </li>
<li>Administer Knowledge<br>Post-Test</li>
<li>Discuss Asthma<br>Case Study</li>
</ul>
</li>
<li><span>Skills Proficiency</span> </li>
<li><span>Simulation in Teams</span>
<ul>
<li>Perform Asthma<br>Simulation</li>
<li>Facilitate<br>Debriefing</li>
</ul>
</li>
<li><span>Performance</span></li>
<li><span>Resources</span></li>
</ul>
</div>
HERE IS MY CSS
#menu {
position: relative;
top: 10px;
left: 0px;
width: 940px;
height: 47px;
}
#menu ul {
position: relative;
top: -15px;
left: 0px;
margin-left: 0px;
padding-left: 0px;
list-style: none;
}
#menu ul li {
position: relative;
display: inline;
float: left;
list-style: none;
margin-right: 0px;
border: solid 0px #4981a8;
width: 156px;
background-image: url ('http://www.laerdal.com/Laerdal/usa/discoversimulation/images/button.png');
background-repeat: no-repeat;
}
#menu ul li a {
display: block;
width: 156px;
padding: 12px 0px 10px 0px;
border: solid 0px #fff;
font-family: 'Cabin', sans-serif;
font-size: 14px;
font-weight: lighter;
text-align: center;
text-decoration: none;
}
#menu a span {
float: left;
display: block;
padding: 3px 5px 4px 6px;
color:#fff;
float: none;
}
#menu a:hover span {
color:#ffdd00;
}
#menu li ul {
position: absolute;
top: 47px;
left: 0px;
background-color:#4981a8;
border: solid 1px #4981a8;
display: none;
}
#menu li:hover ul {
display: block;
z-index: 999;
}
#menu li li a {
font-family: 'Cabin', sans-serif;
font-size: 14px;
color: #000;
font-weight: lighter;
height: 38px;
background-color:#eee;
margin-bottom: -9px;
}
#menu li li a:hover {
color: #065389;
}
You have another element on your page that's partially covering up the navigation:
#textbox {
position: relative;
top: -30px;
}
This is blocking the :hover. To solve this, give your #header a z-index:1. Any positive value should work, you just need to set it to something so the element stays on top.

CSS 'Dropdown' Fix

Afternoon,
I have an issue with my CSS. The third dropdown is placed incorrectly and I have no solution.
Here is what I want:
Before:
http://i53.tinypic.com/2qu85z8.png
After:
http://i51.tinypic.com/241k1on.png
Here is the CSS:
ul.dropdown, ul.dropdown li, ul.dropdown ul {
list-style: none outside none;
}
ul.dropdown {
background: url("../img/nav_bg.png") no-repeat scroll left top transparent;
float: left;
padding: 0 0 3px;
position: relative;
width: 970px;
z-index: 100;
}
ul.dropdown li {
float: left;
font-size: 1.2em;
font-weight: bold;
line-height: 1.2em;
margin: 0;
padding: 0;
position: relative;
}
ul.dropdown li a {
color: #000000;
display: block;
padding: 7px 0;
}
ul.dropdown li a:hover {
color: #0971BA;
}
ul.dropdown li a span {
border-right: 1px solid #D6DBE0;
display: block;
padding: 8px 12px;
}
ul.dropdown li a.active {
color: #0971BA;
}
ul.dropdown li.drop a span {
background: url("../img/nav_icons.png") no-repeat scroll right 13px transparent;
min-height: 0;
padding: 8px 25px 8px 12px;
}
ul.dropdown li.drop:hover {
margin: 0 0 0 -1px;
text-align: left;
}
ul.dropdown li.drop a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 -999em transparent;
}
ul.dropdown li.drop:hover a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 0 #0653AE;
min-height: 0;
}
ul.dropdown li.drop:hover a span {
background-position: right -12px;
border: medium none;
color: #FFFFFF;
padding: 8px 26px 8px 13px;
}
ul.dropdown ul {
left: 0;
margin: 0 0 0 -1px;
overflow: hidden;
padding: 8px 0 0;
position: absolute;
top: 36px;
visibility: hidden;
width: 182px;
z-index: 102;
}
ul.dropdown li ul li {
float: none;
font-size: 12px;
text-shadow: #000 0px 1px 0px;
font-weight: bold;
min-height: 0;
padding: 0;
}
ul.dropdown li.hover, ul.dropdown li:hover {
position: relative;
z-index: 103;
}
ul.dropdown li.drop:hover ul li a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 -54px transparent;
color: #FFFFFF;
display: block;
height: 14px;
min-height: 0;
padding: 7px 12px;
}
ul.dropdown li.drop:hover ul li a:hover {
background-position: 0 -92px;
min-height: 0;
}
ul.dropdown li.drop:hover ul li a span {
background: none repeat scroll 0 0 transparent;
display: inline;
padding: 0;
}
ul.dropdown li.drop:hover ul li.lastChild {
height: 30px;
}
ul.dropdown li.drop:hover ul li.lastChild a {
padding: 7px 12px 9px;
}
ul.dropdown li.drop:hover ul li.lastChild a {
background-position: 0 -130px;
}
ul.dropdown li.drop:hover ul li.lastChild a:hover {
background-position: 0 -168px;
}
ul.dropdown li:hover > ul {
visibility: visible;
}
ul.dropdown li.home a {
background: url("../img/nav_icons.png") no-repeat scroll 14px -36px transparent;
display: block;
min-height: 0;
}
ul.dropdown li.home a:hover {
background-position: 14px -69px;
}
ul.dropdown li.home a:active {
background-position: 14px -102px;
}
ul.dropdown li.home a span {
cursor: pointer;
display: block;
min-height: 0;
padding: 8px 19px 8px 20px;
text-indent: -999em;
}
change the left position of the second and further dropdowns from 0.. usually 100% works if there's already a width on the ul elements
ul.dropdown ul ul {left: 100%;}
which should overrule the left: 0; in this:
ul.dropdown ul {
left: 0;
margin: 0 0 0 -1px;
overflow: hidden;
padding: 8px 0 0;
position: absolute;
top: 36px;
visibility: hidden;
width: 182px;
z-index: 102;
}
NOTE you might also have to overrule (by adding to the extra rule) top: 36px; to top: 0;

Resources