Connecting Tech Pros Worldwide Forums | Help | Site Map

Horizonal list/menu problem in IE

Newbie
 
Join Date: Aug 2008
Posts: 10
#1: Aug 28 '08
Hello,

I've been trying to make a horzontal menu and I'm getting different results in IE. Also I've tried different ways of positioning and was wondering what is the best way.

Underneath is the code for the html and CSS of the menu. I have also attached images of what I mean by different results, hover over them to see.

Firefox 3 (works fine):


Opera 9.51 (works fine):


IE 7 (Changes sizes etc):



CSS:
Expand|Select|Wrap|Line Numbers
  1. /***********************Main navigation Menu *************************/
  2.  
  3. div.navbar {
  4.     padding:10px 2px 0px 6px;
  5.     height:28px;
  6. }
  7.  
  8.  #nav ul {
  9.     list-style-type:none;
  10.     padding:0;
  11.     margin:0 auto;
  12. }
  13.  
  14. #nav li {
  15.     display:inline;
  16. }
  17.  
  18. #nav a {
  19.     background-color:black;
  20.     color:white;
  21.     border:1px solid white;
  22.     padding:.4em 2em;
  23.     text-decoration:none;
  24.     font-variant:small-caps;
  25. }
  26.  
  27.  
  28. #nav a:hover {
  29.     background-color:#1a1a1a;
  30.     filter:alpha;
  31.     opacity:20%;
  32. }
  33.  
  34. #nav a:active {
  35. background-color:#262626;
  36. }
  37.  
HTML
Expand|Select|Wrap|Line Numbers
  1. <div class="navbar">                                                  
  2.  
  3.     <div id="nav">    
  4.      <ul>
  5.      <li><a href="http://www.trance.nu">home</a></li>
  6.      <li><a href="http://www.trance.nu">charts</a></li>
  7.      <li><a href="http://www.trance.nu">blog</a></li>
  8.      <li><a href="http://www.trance.nu">bio</a></li>
  9.      <li><a href="http://www.trance.nu">web design</a></li>
  10.      <li><a href="http://www.trance.nu">web design</a></li>
  11.         </ul>
  12.     </div>
  13. </div>
  14.  
Thanks for any help.

Andrew

Newbie
 
Join Date: Aug 2008
Posts: 10
#2: Aug 28 '08

re: Horizonal list/menu problem in IE


You can now view it at: www.andyboyjlm.obxhost.net


Also someone may be able to tell me why a scrollbar has been added to the browser now that I've uploaded it to a host - I had no scrollbar before and I don't want one unless I incorporate it myself.
Expert
 
Join Date: Aug 2008
Posts: 397
#3: Aug 28 '08

re: Horizonal list/menu problem in IE


Quote:

Originally Posted by AJM Project

You can now view it at: www.andyboyjlm.obxhost.net

Quote:
Also someone may be able to tell me why a scrollbar has been added to the browser...
Good idea to validate the markup and CSS, to also check the page with and without +2 font-scaling in Safari, Opera, and Firefox; and, at text-size "largest" with font-sizes ignored (when setting frozen-fonts) in IE/6 & IE/7; and to check the page in a short window in all above browsers before posting.
Newbie
 
Join Date: Aug 2008
Posts: 10
#4: Aug 28 '08

re: Horizonal list/menu problem in IE


Was that answer just relating to my 2nd post then?

You're going a bit too fast for me here. I'm new, so frozen fonts, font sizes ignored and largest doesn't mean much to me.

I've checked in 3 browsers as you can see, and I've resized them to simulate smallers resolutions etc, which are all good in 1024x768. Anything smaller I'm not bothered about at the moment - I'm just experimenting. I've held control in and scaled a couple of times up with my mouse if that's what you mean by font scaling.

Otherwise I'm not quite sure what you're on about.
Newbie
 
Join Date: Aug 2008
Posts: 6
#5: Aug 29 '08

re: Horizonal list/menu problem in IE


Sorry AJM Project,

but I think in this case IE7 does he's work fine, because he starts top and bottom padding in the middle of text. The others from the bottom of text. I reduced your code to what is necessary to show what I mean

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Menu's</title>
  5. <style type="text/css">
  6. div.navbar {
  7.     height:30px;
  8.     background-color:#767676;
  9.     background-repeat:repeat-x;
  10.     margin-left:1px;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15.   <div class="navbar">                                                  
  16.     Text<BR>
  17.   </div>
  18. </body>
  19. </html>
  20.  
The behavior is for IE7 and FF3 the same. But if you add "padding:20px;" you can see what I mean In IE7 the text is centered between top and bottom. FF3 adds a slight padding at the bottom.

I found a quick and dirty solution: Add after the padding "padding-start=0pt" without a semicolon at the end. It's normally used in XML, I believe.

Another possibility is, because you give navbar a fixed height, give the navbuttons also a fixed height.

I hope, I could help you.
Expert
 
Join Date: Aug 2008
Posts: 397
#6: Aug 29 '08

re: Horizonal list/menu problem in IE


Quote:

Originally Posted by AJM Project

Was that answer just relating to my 2nd post then?.

Yes. You have to start somewhere. Validate the markup and the CSS.
Newbie
 
Join Date: Aug 2008
Posts: 6
#7: Aug 29 '08

re: Horizonal list/menu problem in IE


Quote:

Originally Posted by AJM Project

Was that answer just relating to my 2nd post then?

Hello AJM-Project,

I am also again "Confused? Bewildered? Stuck?".

Sunny1957
Newbie
 
Join Date: Aug 2008
Posts: 10
#8: Aug 29 '08

re: Horizonal list/menu problem in IE


I'm sorry sunny but I don't quite understand what you're trying to say. I tried what I think you said and there is no difference.

David, thanks again. Hopefully I can validate it and then you or someone else will help.
Expert
 
Join Date: Aug 2008
Posts: 397
#9: Aug 29 '08

re: Horizonal list/menu problem in IE


Quote:

Originally Posted by AJM Project

David, thanks again. Hopefully I can validate it and then you or someone else will help.

Good. Once validated, I think you'll need to count on someone else to help. I pretty much summed up my opinion in reply to your thread of Aug 21 subject line: "Div doesn't expand for content, help?"
Expert
 
Join Date: Aug 2008
Posts: 397
#10: Aug 29 '08

re: Horizonal list/menu problem in IE


Regarding the list issue, for whatever reason neither IE/6 or IE/7 is capable of adjusting the glyph height of the small-caps in the last two links. An /ugly/ workaround is to assign a line-height (only px line-height works in this situation) for the IEs (see the conditional comments). Additionally, a little different structure for the list may work better all around.

Please see on-line example here:
horizontal list

Markup and CSS for forum archives below.

FWIW, personally I'd reset to text-transform: uppercase; and delete the small-caps call and the px line-height hack for it...

Expand|Select|Wrap|Line Numbers
  1.  
  2. CSS
  3.  
  4. <style>
  5. html, body {
  6. margin : 0;
  7. padding : 0;
  8. }
  9. body {
  10. font : 100% serif;
  11. text-align : center;
  12. }
  13. #nav {
  14. background : #ddd;
  15. margin : 6px 0 0 0;
  16. padding : 5px 0;
  17. line-height: 1.75;
  18. }
  19. #nav ul {
  20. text-align : center;
  21. padding : 5px 0;
  22. margin : 0;
  23. background-color : #ddd;
  24. color : white;
  25. width : 100%;
  26. }
  27. #nav ul li {
  28. display : inline;
  29. padding : 5px 0;
  30. }
  31. #nav ul li a {
  32. padding : 5px 10px;
  33. background : red;
  34. color : #fff;
  35. text-decoration : none;
  36. border : 1px solid #fff;
  37. font-variant : small-caps;
  38. }
  39. #nav ul li a:hover {
  40. background-color : fuchsia;
  41. color : white;
  42. }
  43.  
  44. </style>
  45.  
  46. <!--[if lte IE 7]>
  47. <style>
  48. /* style for IE/6 */
  49. #nav {padding: 0; }
  50. #nav ul {line-height:18px;}
  51. #nav ul li a {zoom: 1;}
  52. </style>
  53. <![endif]-->
  54.  
  55. <!--[if IE 7]>
  56. <style>
  57. /* style for IE/7 */
  58. #nav {padding: 0; }
  59. #nav ul {line-height:18px;}
  60. #nav ul li a {zoom: 1;}
  61. </style>
  62. <![endif]-->
  63.  
  64.  
  65. HTML
  66. <div id="nav">
  67. <ul id="navlist">
  68. <li><a href="http://www.trance.nu">home</a></li>
  69. <li><a href="http://www.trance.nu">charts</a></li>
  70. <li><a href="http://www.trance.nu">blog</a></li>
  71. <li><a href="http://www.trance.nu">bio</a></li>
  72. <li><a href="http://www.trance.nu">web*design</a></li>
  73. <li><a href="http://www.trance.nu">web*design</a></li>
  74. </ul>
  75. </div>
  76.  
  77.  
  78.  
  79.  
  80.  
Newbie
 
Join Date: Aug 2008
Posts: 10
#11: Aug 30 '08

re: Horizonal list/menu problem in IE


Thanks again David, I appreciate it greatly.

It seems the the small variant was indeed the culprate. The problem is sorted now with the following code..

Expand|Select|Wrap|Line Numbers
  1. div.navbar {
  2.     background-color:green;
  3.     padding:5px 0;
  4.  
  5. }
  6.  
  7.  #nav ul {
  8.     list-style-type:none;
  9.     padding:5px 0;
  10.     margin: 0 0 0 15px;
  11. }
  12.  
  13. #nav li {
  14.     display:inline;
  15. }
  16.  
  17. #nav a {
  18.     background-color:red;
  19.     color:white;
  20.     border:1px solid white;
  21.     padding:.5em 2em;
  22.     text-decoration:none;
  23.     text-transform:uppercase;
  24. }
  25.  
Re the scrollbar prob - my webhost had added extra code and divs to the bottom of my site. I'm trying to consult them about it; I just didn't think this would be the case, hense the question I asked.

Again thank you, hopefully next time I post I will have validation sufficient.

So far my knowledge of HTML and CSS is mainly from reading the book "Sam's Teach Yourself HTML & CSS in 24 Hours", a great book. But obviously it's only beginner level. I have my sites on more advanced books now so hopefully they will help me out with better validation also.

Cheers.
Reply