View Full Version : HELP -> Display Differences in IE and FireFox
DigitalKilroy
09-21-2005, 09:49 PM
I am working on my first web site design, trying to learn CSS.
The menu at the bottom is displayed differently in IE and Firefox, I'm trying to correct this. I want it centered and evenly spaced within 800px.
The Page is up at
http://www.departurestudios.com/preview/index.htm
The CSS is
http://www.departurestudios.com/preview/styles.css
I appreciate any help. I am doing this work for free.
Thanks
macmonkey
09-21-2005, 10:27 PM
Hey, I'm on Mac FF version 1.06 and it looks great. Nothing going wrong at all. Can you describe what's not right w/ either browser and let us know? Even a screenshot would help us help you!
**I don't see too many "bottom" navbars but it nice.. keep it up.
DigitalKilroy
09-22-2005, 03:11 AM
http://www.departurestudios.com/preview/img/menuproblem.jpg
The #menu div won't center the divs inside. See the added space on the right side after the contact us button.
Here is the menu code:
/* Main Nav */
#menu {
width: 800px;
height: 35px;
margin: 0 auto;
padding: 0;
float: left;
}
.team_bt {
width: 134px;
height: 35px;
background-image:url(menu/team_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 2px;
float: left;
}
.team_bt:hover {
background-image:url(menu/team_over.gif);
}
.team_on {
width: 134px;
height: 35px;
background-image:url(menu/team_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 2px;
float: left;
}
.post_bt {
width: 196px;
height: 35px;
background-image:url(menu/post_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0;
float: left;
}
.post_bt:hover {
background-image:url(menu/post_over.gif);
}
.post_on {
width: 196px;
height: 35px;
background-image:url(menu/post_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0px;
float: left;
}
.about_bt {
width: 158px;
height: 35px;
background-image:url(menu/about_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0;
float: left;
}
.about_bt:hover {
background-image:url(menu/about_over.gif);
}
.about_on {
width: 158px;
height: 35px;
background-image:url(menu/about_current.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0;
float: left;
}
.films_bt {
width: 166px;
height: 35px;
background-image:url(menu/films_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0;
float: left;
}
.films_bt:hover {
background-image:url(menu/films_over.gif);
}
.films_on {
width: 166px;
height: 35px;
background-image:url(menu/films_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 2px;
margin-left: 0;
float: left;
}
.contact_bt {
width: 124px;
height: 35px;
background-image:url(menu/contact_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 0;
margin-left: 0;
float: left
}
.contact_bt:hover {
background-image:url(menu/contact_over.gif);
}
webby
09-22-2005, 05:17 AM
I don't see any differences in menu spacing between IE and FF. It's off-center on both browsers, as well as FF.
In order to make them span 800px, you'll need to make the buttons bigger or put space between them. However, I suggest making the total width less than 800px, because anyone with their screen resolution set at 800x600 will get a horizontal scrollbar as it is right now.
vinyl-junkie
09-22-2005, 05:25 AM
I suggest making the total width less than 800px, because anyone with their screen resolution set at 800x600 will get a horizontal scrollbar as it is right now.
Here's a tip that I read somewhere a long time ago. If you're using 800px width resolution, you actually need to specify 780px in order to avoid having a horizontal scrollbar.
Personally, I would avoid specifying pixels and use percent instead, unless you have a specific reason not to do that. Using percent allows the page to stretch or shrink to the visitors browser resolution without this kind of headache.
Vladdy
09-22-2005, 05:33 AM
Seems like you need to trash your current CSS and start over. Open your page in FF (or other Gecko browser) and hit "Ctrl"+"+" a couple of times (something a user with 1600x1200 resolution on 21" Sony Trinitron ;) is likely to do) so you understand my comment.
You might be interested in the following demo I made about sizing page elements depending on the type of their content, before you start your redesign: http://webdeveloper.klproductions.com/demos/layoutoptions.html
_Aerospace_Eng_
09-22-2005, 05:33 AM
Read this (http://www.cssplay.co.uk/menus/centered.html). It explains how to center the menus. If they are just images then you can set the width of the div that contains them to the width of all the images added together.
#menu {
width: 788px;
height: 35px;
margin: 0 auto;
padding: 0;
}
The above should work.
DigitalKilroy
09-22-2005, 05:39 AM
In order to make them span 800px, you'll need to make the buttons bigger or put space between them. However, I suggest making the total width less than 800px, because anyone with their screen resolution set at 800x600 will get a horizontal scrollbar as it is right now.
Thanks for the suggestion. That hadn't crossed my mind. Seriously.
But the problem of the difference in browsers is still not resolved...
I made menu buttons, five in all, to be displayed at the bottom of the page. They have varying widths and line up across the bottom of the box above. I want the buttons (each contained within a div) to line up evenly and center underneath the box above (see image above).
Here is how it is set up - see above code to see how it actually works.
Menu div is 800px, same as the box above it.
Within the menu div are five buttons, each of which add up to 776px when lined up one after another.
[ [b][b][b][b][b] ] = 779px -> the outside brackets refer to the menu div, which is 800px.
What I want it to look like is...
[5px[b]3px[b]3px[b]3px[b]3px[b]5px] = 779px+21px = 800px
Firefox would display that perfectly. Centering the div and evenly spacing the buttons. IE would not, it would push the last button down to a new row, underneath the first button.
So my question is, why did it do that and does anyone have any suggestions as to how to fix it in IE?
If you need more info, let me know. I have the habit of over-complicating explanations.
Vladdy
09-22-2005, 05:44 AM
One other thing: use Strict DTD it makes IE behave better
_Aerospace_Eng_
09-22-2005, 05:45 AM
You are floating the divs they are never going to center with text-align:center; or w/e you need to make the div that contains those divs the width of all of your images plus margins and padding. You really should be using a list for your buttons but w/e its your site.
DigitalKilroy
09-22-2005, 05:46 AM
Sorry, I was writing the above reply when others were posting.
I may go back and rethink my current design with all of your suggestions. Thank you.
If anyone knows why there is a difference though, please let me know.
You really should be using a list for your buttons but w/e its your site.
I was trying to do something with background images and rollovers in the divs. I wasn't sure how to do that with lists. I'm still learning.
_Aerospace_Eng_
09-22-2005, 05:49 AM
Yes IE has a double margin error. It occurs when a margin is put on elements that are floated. It seems to be only the left margin that makes the double margin error occur. The solution is to add display:inline; to your divs that are floated.
DigitalKilroy
09-22-2005, 06:02 AM
Here is the updated code to reflect the changes made to the stylesheet:
/* Main Nav */
#menu {
width: 800px;
height: 35px;
margin: 0 auto;
padding: 0;
display: inline;
float: left;
}
.team_bt {
width: 134px;
height: 35px;
background-image:url(menu/team_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 5px;
float: left;
display: inline;
}
.team_bt:hover {
background-image:url(menu/team_over.gif);
}
.team_on {
width: 134px;
height: 35px;
background-image:url(menu/team_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.post_bt {
width: 196px;
height: 35px;
background-image:url(menu/post_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.post_bt:hover {
background-image:url(menu/post_over.gif);
}
.post_on {
width: 196px;
height: 35px;
background-image:url(menu/post_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.about_bt {
width: 158px;
height: 35px;
background-image:url(menu/about_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0;
float: left;
display: inline;
}
.about_bt:hover {
background-image:url(menu/about_over.gif);
}
.about_on {
width: 158px;
height: 35px;
background-image:url(menu/about_current.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.films_bt {
width: 166px;
height: 35px;
background-image:url(menu/films_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.films_bt:hover {
background-image:url(menu/films_over.gif);
}
.films_on {
width: 166px;
height: 35px;
background-image:url(menu/films_current.gif);
background-repeat: no-repeat;
padding-top: 3px;
margin-right: 3px;
margin-left: 0px;
float: left;
display: inline;
}
.contact_bt {
width: 124px;
height: 35px;
background-image:url(menu/contact_norm.gif);
background-repeat:no-repeat;
padding-top: 3px;
margin-right: 5px;
margin-left: 0px;
float: left;
display: inline;
}
.contact_bt:hover {
background-image:url(menu/contact_over.gif);
It looks better in FF, but still pushes down the contact us button in IE.
DigitalKilroy
09-22-2005, 09:46 PM
One of the coding problems I first ran into was getting the menu rollovers to work using only CSS and as little code as possible.
Take a look at my CSS code in the post above and the menu code from the XHTML page included below. Anyone have a suggestion on how to construct it differently with the same results? Maybe using lists? Also, as it is currently setup, the rollovers don't work in IE.
<div id="menu">
<div class="team_bt"><a href="./teammembers.htm"><img src="img/meet_blank.png" alt="" /></a></div>
<div class="post_bt"><a href="./post.htm"><img src="img/post_blank.png" alt="" /></a></div>
<div class="about_bt"><a href="./about.htm"><img src="img/about_blank.png" alt="" /></a></div>
<div class="films_bt"><a href="./pastfilms.htm"><img src="img/films_blank.png" alt="" /></a></div>
<div class="contact_bt"><a href="mailto:info@departurestudios.com"><img src="img/contact_blank.png" alt="" /></a></div>
</div>
I'm pushed for time today so can't get into each thread as much I would like.
Anyway, I suggest (as have a couple of others), that you use a list for your menu buttons.
Put the buttons into a list:
<ul>
<li><img src="whatever location" /></li>
<li>another img</li>
<li>another </li>
</ul>
If you want the list to pop up/flyout, make the html like this.
<ul>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
</li>
<li></li>
</ul>
see how one list is inside the other?
then use this as your css.
body {
font-family: arial, helvetica, serif;
margin : 0;
}
#mainDD {
font-family : "Arial", verdana, sans-serif, helvetica;
background-color : #940031;
width : 100%;
height : 25px;
text-align : left;
font-size : 0.9em;
}
#mainnav, #mainnav ul { /* all lists */
padding : 3px 3px 3px;
margin : 0;
list-style: none;
line-height: 25px;
color: #eeeeee;
}
#mainnav a {
display: block;
width: 10em;
color : #aaaaaa;
}
#mainnav a:link, #mainnav a:visited, #mainnav a:active, #mainnav a:hover {
color : #cccccc;
text-decoration : none;
background : #940031;
width : 100%;
border : 2px solid #7a0029;
border-bottom : 0;
display : block;
}
#mainnav li { /* all list items */
float: left;
width: 7em; /* width needed or else Opera goes nuts */
padding : 5px 25px 0 0;
}
*mainnav li {
position : absolute;
left : 0px;
top : 0px;
margin-left : 0px;
}
#mainnav li ul { /* second-level lists */
position: absolute;
line-height : 20px;
width: 7em;
left: -999em; /* using left instead of display to hide menus because display: none isn't read by screen readers */
background : #940031;
padding-bottom : 100px;
}
#mainnav li ul ul { /* third-and-above-level lists */
margin: -1em 0 0 7em;
left : -999em;
background : #940031;
}
#mainnav li:hover ul ul, #mainnav li:hover ul ul ul, #mainnav li:hover ul ul ul ul, #mainnav li:hover ul ul ul ul ul, #mainnav li:hover ul ul ul ul ul ul, #mainnav li.sfhover ul ul, #mainnav li.sfhover ul ul ul, #mainnav li.sfhover ul ul ul ul, #mainnav li.sfhover ul ul ul ul ul, #mainnav li.sfhover ul ul ul ul ul ul {
left: -999em; /* added by me */
min-width : 150px;
min-height : 400px;
background : transparent;
height : 400px;
}
/*html*/ #mainnav li:hover ul ul, #mainnav li:hover ul ul ul, #mainnav li:hover ul ul ul ul, #mainnav li:hover ul ul ul ul ul, #mainnav li:hover ul ul ul ul ul ul, #mainnav li.sfhover ul ul, #mainnav li.sfhover ul ul ul, #mainnav li.sfhover ul ul ul ul, #mainnav li.sfhover ul ul ul ul ul, #mainnav li.sfhover ul ul ul ul ul ul {
margin-left : 125px;
top : 50px;
}
#mainnav li, #mainnav li.sfhover {
padding : 0px 25px 0 0px;
}
#mainnav li:hover ul, #mainnav li li:hover ul, #mainnav li li li:hover ul, #mainnav li li li li:hover ul, #mainnav li li li li li:hover ul, #mainnav li li li li li li:hover ul, #mainnav li.sfhover ul, #mainnav li li.sfhover ul, #mainnav li li li.sfhover ul, #mainnav li li li li.sfhover ul, #mainnav li li li li li.sfhover ul, #mainnav li li li li li li.sfhover ul { /* lists nested under hovered list items */
left : auto;
top : 25px;
padding: 0px;
}
#mainnav li a {
background: #940031;
padding: 2px 2px 2px 10px;
font-size : 0.75em;
display : block;
}
#mainnav li li a {
background: #940031;
padding: 2px 10px 2px 15px;
font-size : 0.75em;
display : block;
}
#mainnav li li li li li li a, #mainnav li li li li li li.sfhover a {
background: #940031;
min-width : 200px;
padding: 5px;
display : block;
}
That is the code for many levels of flyouts. I would suggest that you stick it into a separate stylesheet, just for your menu, and then blank out the lines which you think you don't require using the /* comment */ method. Then, if you have accidentally blanked out a line, you won't have lost it completely.
Then to get it to work as a flyout, in IE, (if you need to), you'll need a short bit of JS.
<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById("mainnav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>
Any questions, just ask.
BTW this isn;t my menu code - it's a derivative of the very effective Suckerfish menu.
Bazz
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.