Trying to find why these floated LIs don't align in IE7 - html

Here is the page in question: [redacted]
The menu looks great in Firefox, Safari, Chrome, and IE8+. But in IE7, the LIs are stacked vertically. You can download IETester if you don't already have it to see what I mean.
Here's my HTML:
<ul id="menu">
<li class="you">You</li>
<li class="us">Us</li>
<li class="contact">Contact</li>
<li class="insurance">Insurance</li>
<li class="services">Services</li>
<li class="blog">Blog</li>
</ul>
And the corresponding CSS:
#header #menu {
position: absolute;
bottom: 40px;
right: 22px;
float: right;
}
#menu,
#menu li {
list-style-type: none;
padding: 0;
margin: 0;
}
#menu li {
float: left;
}
#menu a {
display: block;
float: right;
width: 76px;
height: 25px;
padding: 45px 0 5px 0;
text-align: center;
text-decoration: none;
color: #555;
font-size: 90%;
border: 1px solid #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#menu .you a {
background: url(img/icon_you.gif) center 9px no-repeat;
}
#menu .blog a {
background: url(img/icon_blog.gif) center 9px no-repeat;
}
#menu .us a {
background: url(img/icon_us.gif) center 9px no-repeat;
}
#menu .insurance a {
background: url(img/icon_insurance.gif) center 9px no-repeat;
}
#menu .contact a {
background: url(img/icon_contact.gif) center 9px no-repeat;
}
#menu .services a {
background: url(img/icon_services.gif) center 9px no-repeat;
}
#menu a:hover {
background-color: #f6f5f3;
border: 1px solid #e5e2dd;
color: #2871ad;
}
Any insights greatly appreciated.

Define a width for each li element.

Don't float your A-tags. You're already floating the LI wrapper. Also, don't forget to clear your floats at the end of your list.

Related

CSS -Menu work as <a href> with background not just text

my code of menu work fine, but only text is a href, how ever i try to make it a bit more user friendly so make even background in to work as href but its not working, can somebody help me to fix it?
My HTML:
<div id="menu">
<ul>
<li>GAMESITES<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>HRY<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>SERVERY<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>CLANKY<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>FORUM<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>DOWNLOADS<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>BLOGY<span class="arrow"></span></li>
<li class="spacer"> </li>
<li>FLASHOVKY<span class="arrow"></span></li>
</ul>
</div>
My CSS:
#menu{
background-image: url("images/menubg.png");
background-repeat: repeat-x;
height: 44px;
width: 983px;
margin: 0 22px;
}
.spacer{
background-image: url("images/menu_spacer.png");
background-repeat: no-repeat;
width: 1px;
height: 25px;
margin: 0px 12px;
}
#menu ul{
list-style-position: inside; /* Bodka v novom riadku vo vnutry */
list-style-type: none; /* bez bodky */
}
#menu ul li{
padding: 0px 5px 0px 0px;
display: inline-block;
color: #f7f7f7;
}
.arrow{
background-image: url("images/sipka.png");
background-repeat: no-repeat;
width: 10px;
height: 8px;
margin-left: 8px;
display: inline-block;
}
Live preview: http://funedit.com/andurit/try4/
Your markup can be heavily simplified into this:
<div id="menu">
<ul>
<li>GAMESITES</li>
<li>HRY</li>
<li>SERVERY</li>
<li>CLANKY</li>
<li>FORUM</li>
<li>DOWNLOADS</li>
<li>BLOGY</li>
<li>FLASHOVKY</li>
</ul>
</div>
Flexbox solution
If you're willing to explore modern CSS specifications, you can always use flexbox instead of relying on inline-block to position your elements — check out the demo fiddle here: http://jsfiddle.net/teddyrised/9FZS8/
#menu {
background-image: url(http://funedit.com/andurit/try4/images/menubg.png);
background-repeat: repeat-x;
height: 44px;
width: 983px;
font-family: Arial;
}
#menu ul{
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
#menu ul li {
color: #f7f7f7;
flex: 1 1 auto;
}
#menu ul li a {
background-image: url(http://funedit.com/andurit/try4/images/menu_spacer.png);
background-repeat: no-repeat;
background-position: top right;
color: #f7f7f7;
display: block;
padding: 14px 0;
text-decoration: none;
text-align: center;
}
#menu ul li:last-child a {
background: none;
}
#menu ul li a:after {
background-image: url(http://funedit.com/andurit/try4/images/sipka.png);
content: '';
width: 10px;
height: 8px;
margin-left: 8px;
display: inline-block;
}
Non-Flexbox solution
Otherwise, you can always fallback to floating your individual <a> elements, but that requires you to calculate the padding for each of them carefully so the menu does not overflow: http://jsfiddle.net/teddyrised/9FZS8/2/
#menu {
background-image: url(http://funedit.com/andurit/try4/images/menubg.png);
background-repeat: repeat-x;
height: 44px;
width: 983px;
font-family: Arial;
}
#menu ul{
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#menu ul li {
color: #f7f7f7;
}
#menu ul li a {
background-image: url(http://funedit.com/andurit/try4/images/menu_spacer.png);
background-repeat: no-repeat;
background-position: top right;
color: #f7f7f7;
float: left;
padding: 14px 15px; /* Disadvantage: you will have to adjust this padding MANUALLY */
text-decoration: none;
text-align: center;
}
#menu ul li:last-child a {
background: none;
}
#menu ul li a:after {
background-image: url(http://funedit.com/andurit/try4/images/sipka.png);
content: '';
width: 10px;
height: 8px;
margin-left: 8px;
display: inline-block;
}
Add to your links a padding of x and a margin of -x, for example:
#menu a {
padding: 20px;
margin: -20px;
}
Make link to take full space:
li > a{
display:inline-block;
width: 100%;
height: 100%;
}

HTML/CSS - How to make text-overflow in line with each other?

I have a vertical menu and some overflowing text and i'd like to make the text inline with each other. How would i do this?
For example:
http://i754.photobucket.com/albums/xx182/rache_R/text_zpsbd15aa0d.png
HTML:
<div id="sideMenu">
<ul class="top-level">
<li>Back</li>
<li>Accessories & Merchandise</li>
<li>Accident & Roadside Assistance</li>
<li>Customer Relations</li>
<li>E10 Petrol Compatibility</li>
<li>Insurance</li>
<li>Quality & Safety Actions</li>
<li>Shop</li>
<li>Servicing & Maintenance</li>
<li>Servicing Offers</li>
<li>Warranty</li>
</ul>
</div>
CSS:
#sideMenu {
font-size: 11px;
width: 185px;
padding-top: 35px;
padding-left: 15px;
}
#sideMenu ul {
margin: 0;
padding: 0;
}
#sideMenu li {
list-style: none;
padding: 9px;
padding-left: 25px;
}
ul.top-level {
background: #eceeef;
}
ul.top-level li {
border-bottom: 1px solid #FFF;
border-top: 1px solid #FFF;
}
#sideMenu a {
color: #000;
curser: pointer;
display: block;
height: auto;
text-indent: 10px;
text-decoration: none;
width: 100%;
background-image: url(leftMenuArrowBlack.gif);
background-repeat: no-repeat;
background-position: left;
padding-left: 0px;
}
#sideMenu a:hover {
}
#sideMenu li:hover {
background: #fac026;
position: relative;
}
Is this what you want..
Then make your width 200px for #slidemenu..
you can specify text-align:left/right/center in your css to align the text in the vertical menu
Update
you can remove the text-indent and padding-left on the li item and just add text-align:left
#sideMenu a {
color: #000;
curser: pointer;
display: block;
height: auto;
text-align: left;
text-decoration: none;
width: 100%;
background-image: url(leftMenuArrowBlack.gif);
background-repeat: no-repeat;
background-position: left;
padding-left: 0px;
}
checkout the jsfiddle http://jsfiddle.net/8U2H5/1/

Background color on hover & padding

I'm having trouble with having a background color on hover, on a logo and also padding around some images.
For the background-color, it's for the logo that you see on the navigation bar on the left that is CAUL/CBUA. Its' hover state switches to this image and the background on hover should fill the whole block just like the links beside it.
For the padding of the images, it's on the same navigation bar, to the right. They are the social icons I'm sure it's not hard to see where the padding should be.
Here's the link to what I have so far. You can see the navigation bar here.
And here's my CSS:
/* Navigation bar */
#navi {
height: 40px;
background: #1e416f;
font-size: 14px;
color: white;
text-transform: uppercase;
margin: 0 0 20px 0;
}
#navi a:hover {
background: white;
color: #1e416f;
}
.logo {
margin: 5px;
padding: 0;
float: left;
}
.logo a {
float: left;
margin: 2px 10px;
width: 36px;
height: 26px;
background: url(/imgs/navi/caul_white_nav.png) left top no-repeat;
text-indent: -9999px;
}
.logo a:hover {
background: url(/imgs/navi-hover/caul_blue_nav.png) left top no-repeat;
}
#primary-nav, #tools-nav {
list-style: none;
margin: 0;
padding: 0;
}
#primary-nav li, #primary-nav a,
#tools-nav li, #tools-nav a { float: left; }
#primary-nav a, #tools-nav a {
color: white;
text-decoration: none;
padding: 0 10px;
border-right: 1px solid white;
line-height: 40px;
}
#primary-nav li:first-child a, #tools-nav li:first-child a {
border-left: 1px solid white;
}
#tools-nav {
float: right;
}
#tools-nav .icon a {
text-indent: -9999px;
}
#tools-nav .email a {
background: url(/imgs/navi/mail.png) no-repeat;
width: 20px;
}
#tools-nav .email a:hover {
background: url(/imgs/navi-hover/hover_mail.png) no-repeat;
width: 20px;
}
#tools-nav .twitter a {
background: url(/imgs/navi/twitter.png) no-repeat;
width: 20px;
}
#tools-nav .twitter a:hover {
background: url(/imgs/navi-hover/hover-twitter.png) no-repeat;
width: 20px;
}
#tools-nav .search a {
background: url(/imgs/navi/search.png) no-repeat;
width: 20px;
}
#tools-nav .search a:hover {
background: url(/imgs/navi-hover/hover_search.png) no-repeat;
width: 20px;
}
HTML:
<!-- NAVIGATION -->
<div id="navi">
<h1 class="logo">CAUL/CBUA</h1>
<ul id="primary-nav">
<li>Directories</li>
<li>Committees</li>
<li>Resources</li>
<li>About</li>
</ul>
<ul id="tools-nav">
<li class="login">Log In</li>
<li class="email icon">Email</li>
<li class="twitter icon">Twitter</li>
<li class="search icon">Search</li>
</ul>
</div>
May be this will help someone:
.menuItem:hover
and
.menuItem :hover
is not the same, take care!
try this method on active and hover. (background position center center).
#tools-nav .email a {
background: url("/imgs/navi/mail.png") no-repeat scroll center center transparent;
width: 20px;
}
Try this:
#navi.logo {
margin: 5px;
padding: 0;
float: left;
}
#navi .logo a {
float: left;
margin: 2px 10px;
width: 36px;
height: 26px;
background: url(/imgs/navi/caul_white_nav.png) left top no-repeat;
text-indent: -9999px;
}
#navi .logo a:hover {
background: url(/imgs/navi-hover/caul_blue_nav.png) left top no-repeat;
}
Your selector are being overwritten do to CSS Selector scope/order. The more specific overwrites those that are more general, in this case, #navi a:hover is overwriting, .logo a:hover making your hover affect not work. the property you are overwriting is background change it to background-color: white; and you'll be fine

Aligning DIV at bottom of another element causes menus to not be displayed in IE7

I've added markup on a webpage to align a element at bottom of another element. However when I do this the menus on my page aren't displayed in IE7. Here's the markup:
<div id="header">
<div class="panel">
<h1>Heading</h1>
<div class="nav">
<ul>
<li class="hdr"><a class="hdr" href="#">Submenu One</a>
<ul>
<li class="menuitem">Submenu one</li>
<li class="menuitem">Submenu 2</li>
</ul>
</li>
<li class="hdr"><a class="hdr" href="#">Submenu 2</a></li>
<li class="hdr"><a class="hdr" href="#">Submenu 3</a></li>
</ul>
</div>
</div>
</div>
The associated style sheet has the following:
#header
{
position: relative; /* Move to bottom */
height: 100px;
width: 100%;
}
.nav
{
position: absolute; /* Move to bottom */
bottom: 0; /* Move to bottom */
}
#header ul
{
padding-left: 0;
margin-left: 0;
margin: 12px 0px 0px 0px;
list-style: none;
position: relative;
left: -10px;
float: left;
}
#header ul li.hdr
{
display:-moz-inline-stack;
display: inline-block;
zoom: 1;
*display: inline; /* IE Hack */
margin-right: 15px !important;
font-size: 16px;
z-index: 1000;
}
#header ul li a.hdr
{
display: block;
color: white !important;
text-decoration: none;
padding: 9px 11px 11px 11px;
}
#header ul li a.hdr:hover
{
background: #505050;
border: solid 1px #606060;
padding: 8px 10px 10px 10px;
text-shadow: 2px 2px 2px #111;
}
#header ul ul
{
display: none;
border: 1px solid #a0a0a0;
background: #f5f5f5;
position: absolute;
top: 27px;
left: 0px;
zoom: 1;
padding: 10px;
line-height: 20px;
}
#header ul li:hover > ul
{
display: block;
}
#header ul ul li
{
display: block;
}
#header ul ul li a
{
font-size: 12px;
border: none;
color: #000;
background: #f5f5f5;
text-decoration: none;
padding: 8px;
}
The lines with the comment /* Move to bottom */ are responsible for moving the nav div to the bottom of the header. I've tried putting z-index's everywhere, as well as other attributes to ensure IE sees the elements with hasLayout equal to true, but to no avail. I'm pulling my hair out over this, any help much appreciated.
Your IE hack is wrong:
use
*+display: inline; /* IE Hack */
instead of
*display: inline; /* IE Hack */
(star) hack is for IE6 only.
[See here][1]
http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

Mouseover submenu broke

I had a mouseover submenu working very nicely on my site (so nicely in fact that it was working exactly right in Chrome, IE 7 & 8, and FF), but now it's broken somehow and I can't see the problem.
Here's the CSS:
.MainMenu {
width: 90% !important;
min-width: 800px;
height: 42px !important;
padding: 0 0 0 10%;
overflow: hidden;
border-top: 1px solid #0054a6;
border-bottom: 1px solid #0054a6;
background: transparent url("Images/ServiceMenuBG.png");
background-repeat: repeat-x;
}
.MainMenu ul {
padding: 0;
margin:0;
list-style: none;
}
.MainMenu li {
float: left;
position: relative;
height: 31px;
width: 150px;
padding: 11px 0 0 0;
text-align: center;
border-right: 1px solid #0054a6;
}
.MainMenuItem#First { border-left: 1px solid #0054a6; }
.MainMenuItem a {
color: #ffffff;
display: block;
height: 31px;
width: 150px;
font-weight: bold;
text-decoration: none;
}
.MainMenuItem:hover { background: transparent url("Images/ServiceMenuBG.png") repeat-x 0 -42px; }
.SubMenu {
z-index: 500;
display: none;
width: 150px !important;
position: absolute;
top: 10px;
left: 0;
background-color: rgb(51,118,184);
}
.SubMenu li { padding: 0 0 2px 5px; height: 20px !important; width: 143px; }
.SubMenu li a {
height: 20px !important;
font-weight: normal;
color: #ffffff;
text-align: left;
text-decoration: none;
}
.SubMenu li a:hover { text-decoration: underline; }
.MainMenu li.MainMenuItem>ul { top: auto; left: auto; }
.MainMenu li.MainMenuItem:hover ul { display: block; }'
Here's the HTML:
<div class="MainMenu">
<ul>
<li class="MainMenuItem" id="First">Home</li>
<li class="MainMenuItem">Philosophies</li>
<li class="MainMenuItem">Services
<ul class="SubMenu">
<li id="TopItem">Shop Repair</li>
<li>Donations</li>
<li>Consulting</li>
<li id="BottomItem">On-site Service</li>
</ul>
</li>
<li class="MainMenuItem">Contracts</li>
<li class="MainMenuItem">About Us</li>
<li class="MainMenuItem">Contact Us</li>
</ul>
</div>
The SubMenu doesn't display either on mouseover or if I set it's initial display property to block. It's as if it doesn't exist on the page at all.
Thanks in advance for any help.
.MainMenu { overflow: hidden; }
is hiding the sub menus, so remove that line. Line 6 in your CSS.
As Sotiris mentioned
.MainMenuItem a { color: #ffffff; }
hides the top menu items (maybe not on your version because I see you have a background image)