I've got a drop down menu here that just plain won't show up in IE6. The site works perfectly in every other browser. Seems daft to lose sleep over IE6, I know, but the site is for a demographic who could very well still be using it.
Here's the CSS:
html {
height:100%;
}
body, p, a, ul, li, ol, h1, h2, h3, h4, h5, h6 {
margin:0;
padding:0;
}
body {
behavior:url("csshover3.htc");
font-size:14px;
font-family:Arial, Helvetica, sans-serif;
background-color:#d3d3d3;
height:100%;
}
h1 {
font-size:18px;
color:#752eca;
text-decoration:none;
}
h2 {
font-size:14px;
color:#909090;
text-decoration:none!important;
}
p {
text-indent:20px;
color:#000;
}
p a {
color:#000;
text-decoration:underline;
}
p.foot {
text-indent:0px;
}
p.link {
font-size:18px;
color:#30F;
text-decoration:underline!important;
}
a {
color:#4d2288;
text-decoration:none;
outline:none;
}
a:visited {
color:#4d2288;
}
p a:hover {
text-decoration:underline!important;
}
ul#nav {
padding:5px;
margin:0px auto;
width:100%;
}
ul#nav li a {
display:block;
font-weight:bold;
padding:2px 10px;
background:#bacddb;
}
ul#nav li a:hover {
background:#888;
color:#fff;
}
li {
list-style:none;
float:left;
position:relative;
width:225px;
text-align:center;
margin:0px auto;
margin-right:4px;
border:1px solid #4d2288;
}
li ul {
display:none;
position:relative;
width:auto;
top:0;
left:0;
margin-left:-1px;
}
li>ul {
top:auto;
left:auto;
border-top:none;
}
li:hover ul, li.over ul {
display:block;
}
ul#nav li.current a {
background:#b8ab28;
}
ul#nav li.current a:hover {
background:#888;
}
img {
margin:10px 0 5px;
}
*html img {
margin:20px;
}
.coltextimg {
position:relative;
float:left;
background-position:left bottom;
padding:0px 20px 10px 0px;
border:none;
}
#maincontent {
width:940px;
margin:0px auto;
postition:absolute;
}
*html #maincontent {
margin-left:42px;
}
#header {
float:left;
width:100%;
height:auto!important;
height:100%;
min-height:100%;
margin:0px auto;
background-image:url(images/banner_test.jpg);
background-repeat:no-repeat;
border:2px solid #752eca;
-webkit-border-top-left-radius:10px;
-webkit-border-top-right-radius:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-topright:10px;
border-top-left-radius:10px;
border-top-right-radius:10px;
}
.colmask {
position:relative;
margin-top:160px;
clear:both;
float:left;
width:100%;
overflow:hidden;
}
.colright,
.colmid {
float:left;
width:100%;
position:relative;
}
.col1,
.col2 {
float:left;
position:relative;
padding:10px 0 1em 0;
overflow:hidden;
}
.twocol {
background:#fff;
}
.twocol .colmid {
right:45%;
background:#fff;
}
.twocol .col1 {
width:51%;
left:47%;
text-align:justify;
z-index:0;
}
.twocol .col2 {
width:41%;
left:51%;
text-align:justify;
z-index:0;
}
.twocol .colimg {
border:2px solid #a0a0a0;
}
.twocol .colvid1 {
width:360px;
height:240px;
}
.twocol .colvid2 {
width:360px;
height:240px;
}
#footer {
text-align:center;
font-size:9px;
padding:10px 0 1em 0;
clear:both;
width:100%;
height:100%;
}
*html #footer {
height:43px;
}
#footer p a {
text-decoration:none;
}
#lyr_ddmenu {
position:absolute;
z-index:1;
height:10px;
top:120px;
float:left;
width:1000px;
margin:0px auto;
padding:5px;
}
#contact {
position:absolute;
float:right;
font-size:10px;
}
A.Controls:link {
color:#666666;
text-decoration:none;
font-weight:bold;
}
A.Controls:visited {
color:#666666;
text-decoration:none;
font-weight:bold;
}
A.Controls:active {
color:#666666;
text-decoration:none;
font-weight:bold;
}
A.Controls:hover {
color:#be0000;
text-decoration:none;
font-weight:bold;
}
And here's the html I'm having the specific problem with:
<div id="maincontent">
<div id="header">
<div id="lyr_ddmenu">
<ul id="nav">
<li class="current"><href here...</a>
<ul class="sub">
<li><href here...</a></li>
<li><href here...</a></li>
<li><href here...</a></li>
<li><href here...</a></li>
<li><href here...</a></li>
</ul></li>
<li><href here...</a></li>
<ul class="sub">
<li><href here...</a></li>
<li><href here...</a></li>
<li><href here...</a></li>
<li><href here...</a></li>
</ul></li>
<li><href here...</a></li>
<li><href here...</a></li>
<ul class="sub">
<li><href here...</a></li>
</ul></li>
</ul>
</div>
Thanks!
IE6 does not support the :hover pseudo-class for all elements, only a tags, so the following rule will not get applied in IE6:
li:hover ul, li.over ul {
display:block;
}
It looks like your menus are designed to use Javascript to emulate :hover by adding the class over to the li elements using the mouseover functions, so you'll need to post any Javascript before anyone can diagnose what's going on in IE6.
Just on the off chance that this might help, you can use the Whatever:hover script to emulate this behavior in IE6.
1) Remove behavior:url("csshover3.htc"); from the body
2) Add this to the bottom (better replacement of the .htc)
* html li { scrollbar-face-color: expression(runtimeStyle.scrollbarFaceColor = '#fff', onmouseover = function() {this.className += ' hover'}, onmouseout = function() {this.className = this.className.replace(/ hover/g, '')} ); }
li.hover ul { display:block; } /* (li:hover) */
3) Should work.
or try to separate
li:hover ul { display:block; }
li.over ul { display:block; }
You can also use jQuery to handle :hover
jQuery(function($) {
$("li").bind('mouseover mouseout',function(){$(this).toggleClass('hover')});
});
play around .hover class:
li.hover ul { _display: block; } /* Styles for IE6 */
Related
So basically the menu buttons only changes height/width in two directions, and I need to do it three (in both directions left and right, and the bottom).
Here is what it looks like:
http://hijinxnetwork.net/web.html
The CSS:
body {
bakground-image: url('http://i.imgur.com/vjB3x6m.png');
background-repeat:repeat;
background-attachment:fixed;
}
.top {
background-color: #232323;
width:100%;
position:absolute;
top:0;
left:0;
right:0;
height:40px;
}
.header img {
width:450px;
padding-left:650px;
}
.header {
background-color: #101010;
width:100%;
position:absolute;
height:225px;
left:0;
right:0;
top:40px;
}
.nav {
width:900px;
margin:0 auto;
}
.nav ul {
position:relative;
top:179px;
left:auto;
right:auto;
}
.nav li {
float:left;
display:inline;
display:block;
margin-left:3px;
margin-right:3px;
padding-left:20px;
padding-right:20px;
font-family: 'Roboto', sans-serif;
font-weight:100;
text-transform:uppercase;
font-size:24px;
background-color: #363636;
height:50px;
padding-top:20px;
transition: 1s;
}
.nav li:hover {
background-color:#a61919;
height:60px;
font-size:30px;
}
.nav li a {
color:#ffffff;
text-decoration:none;
}
So, if you have any idea on how to change this, that would be great, thanks.
My website loads fine in Chrome, but in Safari my image won't float to the left of my article. Here is a look at the CSS:
body {
background-color:white;
font-family: 'Josefin Slab', serif;
}
.top_portion {
width:820px;
height:200px;
background-color:#e2e2e2;
margin:auto;
text-align:center;
border-top:5px;
border-bottom:5px;
border-left:0px;
border-right:0px;
border-style:solid;
border-color:#30474b;
}
.top_portion img {
padding-top:0px;
}
#welcome h1 {
margin-top:0px;
text-align:center;
padding:0px;
margin-bottom:0px;
}
#welcome h3 {
margin:0px;
text-align:center;
}
#welcome {
margin:auto;
background-color:#e2e2e2;
width:820px;
}
#navigation {
text-align:center;
}
#navigation li {
list-style-type:none;
display:inline;;
}
ul {
font-size:20px;
margin:0;
}
ul a {
padding-right:20px;
text-decoration:none;
color:black;
}
a:hover {
color:#888eee;
}
This is the div containing the image and the article
.info {
width:820px;
margin:auto;
background-color:#e2e2e2;
overflow:hidden;
}
Here is the image
.info img {
padding-top:6px;
padding-left:5px;
}
And here is the article this is and the .info img above should be next to each other but they aren't in Safari which has been updated to the latest version.
article {
padding-left:5px;
font-family:sans-serif;
text-indent:15px;
width:600px;
float:right;
background-color:#e2e2e2;
display:inline-block;
text-align:justify;
}
article h2 {
font-family: 'Carme', sans-serif;
margin-top:5px;
}
h5 {
padding:0;
margin:0;
}
a {
color:black;
}
#bottomlink {
font-size:1.5em;
text-align:center;
}
#bottomlink a {
text-decoration:none;
}
float:left; for the img
and don't bother float:right; on the article
I'm trying to create a horizontal menu with the width of the parent div and where the links are arranged in equal distances. Target is to create a navigation bar with a width of 900px. Maybe it is possible to realize it on another way? I'm a newbie in css and don't know how to fix my problem and hope you could help me!
#nav {
background:red;
width:900px;
}
ul#nav-bar, ul#nav-bar ul{
margin:0;
list-style:none;
padding:0;
background: white;
border: 1px solid black;
}
ul#nav-bar ul{
display:none;
position:absolute;
left:0;
}
ul#nav-bar li:hover>*{
display:block;
}
ul#nav-bar li{
position:relative;
display:block;
white-space:nowrap;
font-size:0;
float:left;
}
ul#nav-bar li:hover{
z-index:1;
}
ul#nav-bar{
font-size:0;
z-index:999;
position:relative;
display:inline-block;
zoom:1;
padding:0;
*display:inline;
}
* html ul#nav-bar li a{
display:inline-block;
}
ul#nav-bar>li{
margin:0;
}
ul#nav-bar a:active, ul#nav-bar a:focus{
outline-style:none;
}
ul#nav-bar a{
display:block;
vertical-align:middle;
text-align:center;
text-decoration:none;
font: 12px Arial;
color:#000000;
padding:5px 10px 5px 10px;
}
ul#nav-bar ul li{
float:none;
margin:0 0 0;
}
ul#nav-bar ul a{
text-align:left;
background-color:red;
color:#000;
}
ul#nav-bar li:hover>a{
background-color:#fff;
color:#000000;
}
ul#nav-bar span{
display:block;
overflow:visible;
background-position:right center;
background-repeat:no-repeat;
padding-right:0px;
}
<div id="nav">
<ul id="nav-bar">
<li>Link1</li>
<li><span>Link2</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link3</li>
<li><span>longxxxxxxxxxxxxxxxxxxxxxxxxxxxlink</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link5</li>
<li>Link6</li>
<li>longxxxxxxxxxxxxxlink</li>
</ul>
</div>
Thanks!
To get the #nav-bar to match the parent, simply add width:100% to your existing ul#nav-bar tag in css. This tells your child to fill up the parent, regardless of child's content.
As for spreading out the links, it has been my experience that the best way to do this is to add margins to the text once the navbar is complete. For your coded example, I would add the following to even them out:
ul#nav-bar->li{
margin:0px 20px 0px 20px;
text-align:center;
}
You can view it here and here is the css code
/*zero-height container problem fix for floated elements*/
.clearfix:before,
.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
}
#nav {
background:#999;
width:900px;
}
#nav ul{
list-style: none;
padding: 0;
margin: 0;
}
#nav li{
position: relative;
text-align: center;
padding: 10px 0px;
}
#nav a{
text-decoration: none;
display: block;
color: #f0f0f0;
}
#nav-bar > li{
float: left;
}
#nav-bar ul{
position: absolute;
left: 0;
width: 100%;
top: 100%;
background: #999;
display: none;
}
#nav-bar li:hover{
background: #666;
}
#nav-bar li:hover ul{
display: block;
}
As if you want width to be adjusted to text width in li elements so you need javascript
and here is the code i have updated the jsfiddle
$(document).ready(function(){
total_nav_width = $('#nav').width();
main_link = $('#nav-bar > li > a')
textWidths = [];
totalTextWidth = 0;
main_link.each(function(){
textWidths.push($(this).width())
})
for (var i = 0; i < textWidths.length; i++) {
totalTextWidth += textWidths[i];
}
additionValues = (total_nav_width - totalTextWidth)/main_link.length;
main_link).each(function(){
intialWidth = $(this).width()
$(this).width( intialWidth + additionValues )
})
})
I am trying to make my menu links #666666 and then on hover make it #FFFFFF
i want these colours to change on the text colour and the top border
http://jsfiddle.net/4Xdkn/
#topbar {
width:100%;
height:80px;
background-color:#000000;
}
#topbar-inner {
width:1000px;
margin:0 auto 0 auto;
}
#logo {
display:inline;
float:left;
margin-top:20px;
}
#menu {
display:inline;
float:right;
}
#menu > ul > li {
display:inline-block;
border-top:4px solid #666666;
margin-right:20px;
padding-top:20px;
min-width:120px;
}
#menu > li {
display:inline-block;
list-style:none;
margin-top:25px;
margin-left:auto;
margin-right:auto;
}
#menu > li:hover {
color:#FFFFFF;
}
Selectors should be
#menu li a {
color: #666;
display: block;
}
#menu li:hover {
border-top-color: #FFF;
}
#menu li:hover a {
color:#FFFFFF;
}
#menu has no direct li descendants so #menu > li:hover does not match anything.
http://jsfiddle.net/4Xdkn/8/
You have an error in your CSS
#menu > li does not target anything, since #menu is applied to a div and it has no direct children of type li.
Use these rules
#menu li {
display:inline-block;
border-top:4px solid #666666;
margin-right:20px;
padding-top:20px;
min-width:120px;
}
#menu li:hover,
#menu li:hover a {
color:#FFFFFF;
}
#menu li a {
color:#666666;
}
#menu li:hover {
border-color:#FFFFFF;
}
Demo at http://jsfiddle.net/gaby/4Xdkn/4/
Updated Fiddle
You need to add:
#menu li a {
display:block;
padding-top:25px;
border-top:4px solid #666666;
}
#menu
li a:hover {
border-color:red;
color:#fff
}
On #menu > ul > li remove the border-top and padding, because this has been added to the a tag now.
On #menu > li remove the margin-top property
try this
http://jsfiddle.net/4Xdkn/7/
#topbar {
width:100%;
height:80px;
background-color:#000000;
}
#topbar-inner {
width:1000px;
margin:0 auto 0 auto;
}
#logo {
display:inline;
float:left;
margin-top:20px;
}
#menu {
display:inline;
float:right;
}
#menu > ul > li {
display:inline-block;
border-top:4px solid #666666;
margin-right:20px;
padding-top:20px;
color:#ffffff;
min-width:120px;
}
#menu > li > a {
display:inline-block;
list-style:none;
margin-top:25px;
margin-left:auto;
margin-right:auto;
text-decoration:none;
color:#ffffff;
text-decoration:none;
}
#menu li:hover {
color:#FFFFFF !important;
text-decoration:none;
border-top:4px solid #ffffff;
display:inline-block;
}
#menu li a:hover{
color:#ffffff;
text-decoration:none;
}
}
Colorize the a-element instead of the li and make the a element as big as the li.
#menu li a:hover {
color:white;
border-style:solid;
border-width: 1px 0px 0px 0px;
border-color:white;
}
Try the below css
#topbar {
width:100%;
height:80px;
background-color:#000000;
}
#topbar-inner {
width:1000px;
margin:0 auto 0 auto;
}
#logo {
display:inline;
float:left;
margin-top:20px;
}
#menu {
display:inline;
float:right;
}
#menu > ul > li {
display:inline-block;
margin-right:20px;
min-width:120px;
}
#menu > li {
list-style:none;
padding:25px 0 0 0;
margin-left:auto;
margin-right:auto;
border-top:1px solid #fff;
}
#menu ul li a:hover {
color:#FFFFFF;
}
#menu li a {display:block; padding:20px 0 0 0;border-top:4px solid #666666;}
#menu li a:hover { border-top:4px solid #fff; color:#fff}
I have a CSS driven simple drop down menu that can appear in double rows on narrower screens.
When I activate the dropdown of one of the top row items the drop down appears at the same "Z" level as the bottom row.
I thought I've set the z-indexes as required but it isn't working in Chrome, Firefox, Safari or iPhone.
Here is a sample: http://jsfiddle.net/bNBp3/ - "Meat" has a dropdown attached.
<ul id="main-navigation">
<li><span>Home</span>
</li>
<li><span>Meat</span>
<ul>
<li><span>Bacon</span></li>
<li><span>Ham</span></li>
<li><span>Pork</span></li>
</ul>
</li>
<li><span>Vegetables</span>
</li>
<li><span>About Us</span>
</li>
<li><span>Contact Us</span>
</li>
<li><span>A-Z</span>
</li>
</ul>
ul#main-navigation {
display:block;
border-bottom:1px solid #ccc;
margin:0 auto 0px auto;
min-height:21px;
padding:0;
width:100%;
z-index:11;
clear:both;
}
ul#main-navigation li {
display:block;
float:left;
list-style:none;
margin:0 5px 0 0;
padding:0;
position:relative;
z-index:12;
min-height:22px;
min-width:30%;
}
ul#main-navigation li a {
color:#000;
display:block;
padding:2px;
text-decoration:none;
z-index:13;
}
ul#main-navigation li a.current, ul#main-navigation li a.section {
color:#fff;
}
ul#main-navigation li ul {
background:#eee;
position:absolute;
left:-1px;
top:21px;
display:none;
overflow:hidden;
padding:0px;
z-index:14;
width:100%;
border:1px solid #ccc;
}
ul#main-navigation li ul li {
display:block;
float:none;
margin:0;
z-index:15;
width:100%;
border-bottom:1px solid #ccc;
}
ul#main-navigation li ul li a {
background:#eee;
display:block;
color:#333;
z-index:16;
zoom:100%;
}
ul#main-navigation li ul li a:hover {
background:#fff;
}
ul#main-navigation li:hover {
background:#eee;
border-left:1px solid #ccc;
border-right:1px solid #ccc;
}
ul#main-navigation li:hover a.current {
background:#eee; color:#000;
}
ul#main-navigation li:hover ul {
display:block;
}
Just get rid of all the z-index values and it works fine:
http://jsfiddle.net/bNBp3/12/
Tested in Chrome and Firefox6.
Edit: It seems I forgot to remove the z-index from ul#main-navigation li ul in the demo and that's what makes it work, so just set it to any value 1 or higher.