I have a problem with Firefox I have a drop down menu at the top of my website this is the code for the CSS
#zone-bar {
background:#E5E5E5;
min-height:30px;
z-index:10;
padding:5px 10px 0;
}
#zone-bar ul li {
float:left;
height:18px;
margin-right:10px;
position:relative;
z-index:10;
padding:5px 5px 0;
}
#zone-bar ul li:hover {
background:#C0C0C0;
}
#zone-bar ul li a {
color:#383838;
display:block;
float:left;
font-size:1.1em;
font-weight:700;
height:23px;
padding-right:3px;
position:relative;
right:-5px;
text-decoration:none;
top:-5px;
}
#zone-bar ul li a:hover,#zone-bar ul li a.zoneCur {
background:url(images/right-hover.png) center right no-repeat;
z-index:10;
}
#zone-bar ul li a span {
position:relative;
top:6px;
}
#zone-bar ul li ul {
background:#FFF;
border:1px solid #ccc;
display:none;
left:0;
position:absolute;
top:29px;
width:150px;
padding:10px 0 0;
}
#zone-bar ul li ul li {
float:none;
height:100%;
margin:0;
padding:0;
}
#zone-bar ul li ul li:hover {
background:none;
}
#zone-bar ul li ul li a {
display:block;
float:none;
margin-left:-5px;
width:140px;
padding:5px 0 0 10px;
}
#zone-bar ul li ul li a:hover {
background:#C0C0C0;
}
#zone-bar ul {
display:block;
}
This is my HTML code
<div id="zone-bar">
<ul><li>
<span>My Account <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>My Account</li>
<li>My Channel</li>
<li>My Videos</li>
<li>Favorites</li>
<li>Playlists</li>
<li>Friend Requests (1)</li>
<li>Logout</li>
</ul></li>
<li>
<span>Messages <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Messages (1)</li>
<li>Compose New Message</li>
<li>Notifications (0)</li>
</ul></li>
<li>
<span>Videos <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Recent</li>
<li>Viewed</li>
<li>Featured</li>
<li>Top Rated</li>
<li>Commented</li>
</ul></li>
<li>
<span>Channels <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Recent</li>
<li >Viewed</li>
<li >Featured</li>
<li >Top Rated</li>
<li >Commented</li>
</ul></li>
<li>
<span>Groups <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Create New Group</li>
<li>All Time</li>
<li>Today</li>
<li>Yesterday</li>
<li>This Week</li>
<li>Last Week</li>
<li>This Month</li>
<li>Last Month</li>
<li>This Year</li>
<li>Last Year</li>
</ul></li>
<li>
<span>Upload <em><img src="images/arrow.png" alt="dropdown"></em></span>
<ul>
<li>Upload New Video</li>
<li>My Videos</li>
</ul></ul>
</div>
you can see a live demo at doctorwhohd.com
The problem im facing is this in normal all browsers except Firefox it looks like this when you hover over the items
In Firefox all versions i get this
Any help would be great! as this is a problem which i cannot seem to fix and im sure there is something im missing.
Your markup is really ugly for starters,
why have extra <span> tags in the top level <li> tags, why wrap your <img> tags with <em> and don't use for styling purposes.
Clean that up first.
Second, you have a lot of absolute and relative position styles that don't appear to be necessary. Have you tried styling your nav without the use of relative and absolute positioning.
The only place I see relative positioning being useful here is for the little arrow images.
Try that out.
You can give each #zone-bar ul li an explicit width (since it is the width of the li that is overrunning its content).
You may want to give each li an ID or class so that you can control their widths individually.
Related
Here yellow is <li> which is child of <ul> at the moment <li> or <ul> don't have float:left or display:inline as soon as I apply either float or display on <li> or <ul>
pink <li> which is child of nested <ul> changes it's appearance to this
<ul class="top_nav">
<li>name
<ul class="sub_nav">
<li>name1 icnkdn ndkcnks kkncksn </li>
<li>name2</li>
<li>name3</li>
</ul>
</li>
<li>home</li>
</ul>
.top_nav{
list-style-type:none;
padding:0;
}
.top_nav > li {
padding:1em 2em;
background:yellow;
position:relative;
}
.sub_nav{
position:absolute;
z-index:1;
background:green;
}
.sub_nav li{
display:block;
background:pink;
padding:1em 3em;
}
https://codepen.io/labeeb/pen/zRxoOR
Your .sub_nav has position: absolute; that's why your <li> element is collapsed. Remove this property and everything will be ok.
I have a CSS3 Menu. When a menu items text is too long the design breaks. I want the text to simply move up to fit
the text. For example: At www.casa.gov.au the menu item text REGULATIONS AND POLICY starts higher than the rest
of the items. This prevents the menu width and height changing to fit the larger text.
How would I go about doing this with the menu attached in the JS FIDDLE: http://jsfiddle.net/UU4rm/
The problem is associated with the line height at #css li a { }
CSS CODE
/* MENU */
#cssmenu {
border:none;
border:0px;
margin:0px;
padding:0px;
font-size:12px;
font-weight:bold;
border-bottom: solid 1px rgb(77,77,77);
}
#cssmenu ul {
background:#333333;
height:39px;
list-style:none;
margin:0;
padding:0;
display: table;
width: 100%;
}
#cssmenu li {
padding:0px;
display: table-cell;
width: 115px;
}
#cssmenu li a {
background:#333333 url('../images/seperator.gif') bottom right no-repeat;
color:#FFF;
display:block;
font-weight:normal;
line-height:39px;
margin:0px;
padding:0px 0px;
text-align:center;
text-decoration:none;
width: 115px;
}
#cssmenu li a:hover,
#cssmenu ul li:hover a,
#cssmenu li a:focus,
#cssmenu ul li:focus a{
background: #2580a2;
color:#FFFFFF;
text-decoration:none;
float: none;
}
#cssmenu li ul {
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:230px;
z-index:200;
/*top:1em;
/*left:0;*/
}
#cssmenu li.force-show ul,
#cssmenu li:hover ul,
#cssmenu li a:focus + ul{
display:block;
}
#cssmenu li li {
background:url('../images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:230px;
}
#cssmenu li:hover li a,
#cssmenu li:focus li a {
background:none;
}
#cssmenu li ul a {
display:block;
height:35px;
font-size:11px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
width: 205px;
}
#cssmenu li ul a:hover,
#cssmenu li ul li:hover a,
#cssmenu li ul a:focus,
#cssmenu li ul li:focus a{
background:#2580a2 url('../images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
width: 205px;
}
#cssmenu p {
clear:left;
}
:focus {
outline:none;
}
::-moz-focus-inner {
border:0;
}
HTML CODE
<div id="cssmenu"> <ul> <li>Home</li>
<li class="has-sub"> Operations <ul>
<li>Individuals
</li>
<li>Aircraft owners
</li>
<li>Aircraft operators
</li>
<li>Flight training
</li>
<li>Aerodromes
</li>
<li>Office of airspace regulation
</li>
<li>Sport aviation
</li>
<li>Class D
</li>
<li>Non-towered aerodromes
</li>
<li>Dangerous goods
</li>
<li>Ground operations
</li>
<li>Non-compliance notice
</li>
<li>Unmanned Aircraft Systems (UAS)
</li>
<li>General Aviation (GA) task force
</li>
<li>Regional Aviation Safety Forum (RASF)
</li>
<li>Drug and Alcohol Management Plans
</li>
</ul></li>
<li class="has-sub"> Airworthiness <ul>
<li>Maintenance regulations
</li>
<li>Personnel
</li>
<li>Certification and design
</li>
<li>Manufacturing
</li>
<li>Continuing airworthiness
</li>
<li>Airworthiness directives
</li>
<li>Maintenance organisations
</li>
<li>Flight test and evaluation
</li>
</ul></li>
<li class="has-sub"> Regulations & Policy <ul>
<li>Current rules
</li>
<li>Changing the rules
</li>
<li>Enforcement action
</li>
<li>Policy notices
</li>
<li>Australia's state safety program
</li>
<li>Performance based navigation (PBN)
</li>
<li>Licensing regulations
</li>
</ul></li>
<li class="has-sub"> Manuals & forms <ul>
<li>Manuals
</li>
<li>Forms
</li>
<li>CASA online store
</li>
<li>Temporary Management Instructions (TMIs)
</li>
</ul></li>
<li class="has-sub"> Education <ul>
<li>AviationWorx
</li>
<li>eLearning catalogue
</li>
<li>Flight Safety Australia
</li>
<li> Pilot guides and information
</li>
<li>OnTrack
</li>
<li>Human factors
</li>
<li>Safety management systems
</li>
<li>Seminars and workshops
</li>
<li>Aviation safety advisers
</li>
<li>Advice for air travellers
</li>
<li>CASA online store
</li>
<li>Out-n-Back
</li>
</ul></li>
<li class="has-sub"> Services <ul>
<li>Licences & registrations
</li>
<li>Self Service Portal
</li>
<li>Service standards & fees
</li>
<li>Permission application centre (PAC)
</li>
<li>Aviation medicals
</li>
<li>Delegates and authorised persons
</li>
</ul></li>
<li class="has-sub"> About CASA <ul>
<li>Contact CASA
</li>
<li>CASA board
</li>
<li>CASA's Director
</li>
<li>Recent media releases
</li>
<li>Corporate publications
</li>
<li>CASA on Twitter
</li>
<li>Corporate policy
</li>
<li>Careers at CASA
</li>
<li>Research and statistics
</li>
</ul></li>
</ul>
</div>
It looks to me (in FF), that it's the bottom border attribute that's causing a goofy black line under your menu.
#cssmenu {
border-bottom: solid 1px rgb(77,77,77);
}
Eliminating that bottom border attribute, and adding addition text to the menu items (causing a wrap/second line) acted as expected.
I am trying to work out why I can not navigate our menu which uses multiple unordered lists via keyboard.
Does anyone have any tips? I have a feeling its more of a CSS issue than html.
RELATED CSS:
/* MENU */
#cssmenu{
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:11px;
font-weight:bold;
}
#cssmenu ul{
background:#333333;
height:39px;
list-style:none;
margin:0;
padding:0;
display: table;
width: 100%;
}
#cssmenu li{
padding:0px;
display: table-cell;
width: 115px;
}
#cssmenu li a{
background:#333333 url('../images/seperator.gif') bottom right no-repeat;
color:#FFF;
display:block;
font-weight:normal;
line-height:39px;
margin:0px;
padding:0px 0px;
text-align:center;
text-decoration:none;
width: 115px;
}
#cssmenu li a:hover, #cssmenu ul li:hover a{
background: #2580a2;
color:#FFFFFF;
text-decoration:none;
float: none;
}
#cssmenu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:230px;
z-index:200;
/*top:1em;
/*left:0;*/
}
#cssmenu li:hover ul{
display:block;
}
#cssmenu li li {
background:url('../images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:230px;
}
#cssmenu li:hover li a{
background:none;
}
#cssmenu li ul a{
display:block;
height:35px;
font-size:10px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
width: 205px;
}
#cssmenu li ul a:hover, #cssmenu li ul li:hover a{
background:#2580a2 url('../images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
width: 205px;
}
#cssmenu p{
clear:left;
}
:focus {outline:none;}
::-moz-focus-inner {border:0;}
RELATED HTML CODE:
<div id="cssmenu"> <ul> <li>Home</li>
<li class="has-sub"> Operations <ul>
<li>Individuals
</li>
<li>Aircraft owners
</li>
<li>Aircraft operators
</li>
<li>Flight training
</li>
<li>Aerodromes
</li>
<li>Office of airspace regulation
</li>
<li>Sport aviation
</li>
<li>Class D
</li>
<li>Non-towered aerodromes
</li>
<li>Dangerous goods
</li>
<li>Ground operations
</li>
<li> Non-compliance notice
</li>
<li>Unmanned Aircraft Systems (UAS)
</li>
<li>General Aviation (GA) task force
</li>
<li>Regional Aviation Safety Forum (RASF)
</li>
<li>Drug and Alcohol Management Plans
</li>
</ul></li>
<li class="has-sub"> Airworthiness <ul>
<li>Maintenance regulations
</li>
<li>Personnel
</li>
<li>Certification and design
</li>
<li>Manufacturing
</li>
<li>Continuing airworthiness
</li>
<li>Airworthiness directives
</li>
<li>Maintenance organisations
</li>
<li>Flight test and evaluation
</li>
</ul></li>
<li class="has-sub"> Regulations & policy <ul>
<li>Current rules
</li>
<li>Changing the rules
</li>
<li>Enforcement action
</li>
<li>Policy notices
</li>
<li>Australia's state safety program
</li>
<li>Performance based navigation (PBN)
</li>
<li>Licensing regulations
</li>
</ul></li>
<li class="has-sub"> Manuals & forms <ul>
<li>Manuals
</li>
<li>Forms
</li>
<li>CASA online store
</li>
</ul></li>
<li class="has-sub"> Education <ul>
<li>AviationWorx
</li>
<li>eLearning catalogue
</li>
<li>Flight Safety Australia
</li>
<li> Pilot guides and information
</li>
<li>OnTrack
</li>
<li>Human factors
</li>
<li>Safety management systems
</li>
<li>Seminars and workshops
</li>
<li>Aviation safety advisers
</li>
<li>Advice for air travellers
</li>
<li>CASA online store
</li>
<li>Out-n-Back
</li>
</ul></li>
<li class="has-sub"> Services <ul>
<li>Licences and registrations
</li>
<li>Service standards and fees
</li>
<li>Self Service Portal
</li>
<li>Permission application centre (PAC)
</li>
<li>Aviation medicals
</li>
<li>Delegates and authorised persons
</li>
</ul></li>
<li class="has-sub"> About CASA <ul>
<li>Contact CASA
</li>
<li>CASA board
</li>
<li>CASA's Director
</li>
<li>Recent media releases
</li>
<li>Corporate publications
</li>
<li>CASA on Twitter
</li>
<li>Corporate policy
</li>
<li>Careers at CASA
</li>
<li>Research and statistics
</li>
<li>International Engagement
</li>
<li>CASA mailing lists
</li>
</ul></li>
</ul>
</div>
It is not working because you only have :hover rules which the keyboard does not trigger. When an element has tab focus it has the :focus pseudo-class, you will notice when you add this that your menu items light up when focused but still don't open the menu.
jsFiddle: With :focus rules along side :hover rules
This is due to the following rule:
#cssmenu li:hover ul,
#cssmenu li:focus ul{
display:block;
}
The li never actually gets focus because it has no tab index, the a inside of li gets focus. Since li is a parent of ul but a is a sibling of ul we need to use a different rule to get this targeting to work. We can use the next sibling selector + to target the ul based on a:focus. This gets us one step closer.
#cssmenu li:hover ul,
#cssmenu li a:focus + ul{
display:block;
}
jsFiddle with the above applied
Unfortunately this is as far as you can go with CSS (as far as I'm aware). When we try to go to the next a, :focus will be dropped on the top-level a and the menu will hide as the sub-menu will lose display:block;. Since we can't traverse up the tree when applying styles there is no way we can apply display:block to the ancestor ul when we :focus an a further down.
The only way I can see getting around this is to use JavaScript and handle the focus (and maybe blur()) event for the top-level menu items. We must then also handle the click() event to hide the menu when clicking anywhere in the document otherwise it will stay active.
jsFiddle fully working
CSS
#cssmenu li.force-show ul,
#cssmenu li:hover ul,
#cssmenu li a:focus + ul{
display:block;
}
JS
$('#cssmenu > ul > li > a').focus(function () {
$('#cssmenu > ul > li').removeClass('force-show');
$(this).parent().addClass('force-show');
});
// Clear the menu class if clicked anywhere in the document.
$(document).click(function () {
$('#cssmenu > ul > li').removeClass('force-show');
});
The problem is, that focus in CSS does not bubble up. The nearest I come is this:
/* for instance use it that way */
#cssmenu li a:hover,
#cssmenu li a:focus,
#cssmenu ul li:hover a,
#cssmenu ul li:focus a { }
The example works for the first level. But while going to the second, the first loses it's :focus, and so the submenu is hidden again. I think you need to help a bit with JavaScript.
Ive been trying to make the original dropdown into multi level for a site im working on. All of my attempts have failed (. For some reason i can only do "margin-right" to align the elements, and this causes some problems. I think it has something to do with the position attribute.
Here is my HTML:
<ol id="nav">
<li>Home</li>
<li class="dropdown_alignedLeft">
Products
<ul><li class="dropdown_alignedRight">
iPoP
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>iPoP - Network Solutions for Vessels</li></ul><li class="dropdown_alignedRight">
Cameras
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>iCam 501 Ultra - Intrinsically Safe Digital Camera with Flash</li></ul><li class="dropdown_alignedRight">
BNWAS
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>BNWAS - Bridge Navigation Watch Alarm System</li></ul><li class="dropdown_alignedRight">
Lighting
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>Peli 2690 - Intrinsically Safe LED Head Lamp</li></ul><li class="dropdown_alignedRight">
Communication
<ul style="margin-right:-400px; top:0px;-webkit-border-top-right-radius: 5px;border-top-right-radius: 5px;-moz-border-radius-topright: 5px;"><li>Ex-Handy 06 - Intrinsically Safe Cell Phone</li></ul>
</ul>
<li class="dropdown_alignedLeft">
Customers
<ul>
<li>Maritime</li>
<li>Non-Maritime</li>
<li class="dropdown_lastItem">Regulatory Organizations</li>
</ul>
<li>Product Enquiry</li>
<li>Contact Us</li>
<li class="dropdown_alignedLeft">
Company
<ul>
<!-- <li>About Us</li> -->
<li>News</li>
<li class="dropdown_lastItem">Press Releases</li>
</ul>
</ol>
And my CSS:
#nav {
float:right;
margin:15px 0 0;
}
#nav li {
float:left;
}
#nav li a {
display:block;
font-family:"PT Sans","Helvetica Neue",Arial,sans-serif;
font-size:16px;
text-decoration:none;
color:#2B95C8;
padding:10px 20px 20px;
}
.dropdown_alignedLeft,.dropdown_alignedRight {
position:relative;
}
#nav .dropdown_alignedLeft>a,#nav .dropdown_alignedRight>a {
background:url(../images/dropdown_arrow_blue.png) no-repeat top right;
padding:10px 30px 20px 20px;
}
#nav .dropdown_alignedLeft:hover>a,#nav .dropdown_alignedRight:hover>a {
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
-moz-border-radius-bottomright:0;
-moz-border-radius-bottomleft:0;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
-webkit-border-bottom-right-radius:0;
-webkit-border-bottom-left-radius:0;
border-top-left-radius:5px;
border-top-right-radius:5px;
border-bottom-right-radius:0;
border-bottom-left-radius:0;
color:#FFF;
background:#2378A1 url(../images/dropdown_arrow_blue.png) no-repeat bottom right;
}
.dropdown_alignedLeft ul,.dropdown_alignedRight ul {
display:none;
}
#nav .dropdown_alignedLeft:hover>ul,#nav .dropdown_alignedRight:hover>ul {
display:block;
z-index:100;
position:absolute;
top:50px;
-moz-border-radius-topleft:0;
-moz-border-radius-topright:0;
-moz-border-radius-bottomright:5px;
-moz-border-radius-bottomleft:5px;
-webkit-border-top-left-radius:0;
-webkit-border-top-right-radius:0;
-webkit-border-bottom-right-radius:5px;
-webkit-border-bottom-left-radius:5px;
border-top-left-radius:0;
border-top-right-radius:0;
border-bottom-right-radius:5px;
border-bottom-left-radius:5px;
background:#2378A1;
padding:0 0 6px;
}
#nav .dropdown_alignedRight:hover>ul {
top:50px;
right:0;
text-align:right;
}
#nav li ul li {
float:none;
border-bottom:1px dashed #2B95C8;
margin:0 20px;
}
#nav li ul li.dropdown_innerTitle {
border:none;
font-family:"Helvetica Neue",Arial,sans-serif;
font-size:15px;
white-space:nowrap;
color:#C8DDE7;
margin:10px 20px 0;
padding:10px 0;
}
#nav li ul li.dropdown_lastItem {
border:none;
}
#nav li ul li a {
font-family:"Helvetica Neue",Arial,sans-serif;
font-size:13px;
color:#FFF;
white-space:nowrap;
padding:10px 0 9px;
}
#nav>li:hover>a,#nav li .current_page {
color:#2378A1;
background:url(../images/current_page_arrow_blue.png) no-repeat center bottom;
}
#nav li ul li a:hover {
color: #C8DDE7;
}
For a live version of the menu, please go here:
JSFiddle - Live Menu
You weren't closing a lot of your li tags and your submenu was just sort off flying off its container. Cleaned up your code and made too many modifications to list here:
http://jsfiddle.net/MmHSd/4/
http://purecssmenu.com/ Might help you out. Try downloading a list and taking a look at it. Deleting all the extra tags you have and take everything back to a basic list like this:
<ul>
<li>Element 1</li>
<li>Element 2</li>
<ul>
<li>
Element 2 Child 1
</li>
<li>
Element 2 Child 2
</li>
</ul>
and working back up to something a bit more complicated might help too.
I trying to set up my nav so I have my list items and i have a list inside a list item (sub-menu) like so...
<style>
.headerNav{
color:#FFF;
margin:0 auto;
width: 1280px;
padding-top: 148px;
}
.headerNav ul{
list-style-type:none;
margin:0;
padding:0 0 0 8px;
}
.headerNav li{
float:left;
}
.headerNav ul a{
font-size:24px;
color:#FFF;
display:block;
padding:0 55px 0 0;
text-decoration:none;
text-transform:capitalize;
}
.headerNav ul a:hover{
color:#a40404;
text-decoration:none;
}
</style>
<div class="headerNav">
<ul>
<li>Home</li>
<li><a href="#" class='galleryNavToggle'>Gallery</a>
<ul>
<li>Categoies</li>
<li>Products</li>
</ul>
</li>
<li><a href="#" class='galleryNavInfoToggle'>Info</a>
<ul>
<li>F.A.Q.</li>
<li>CV</li>
<li>Artist Bio</li>
<li>Video</li>
<li>Contact</li>
</ul>
</li>
</ul>
</div><!-- headerNav -->
The problem is that the list items with a list inside have a massive width and I cant see my sub nav at all, any help would be greatly appreciated.
I've created a fiddle with your html and css and added a bit of css of my own to outline the sublist a bit better: http://jsfiddle.net/bymLV/
I removed float: left from the sublist, because this is what makes your list so extremely wide. That and the actual width of 1280px you are giving .headerNav.