www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Horizontal menu, Opera not behaving properly

  1. #1
    Join Date
    Dec 2002
    Location
    Göteborg, Sweden
    Posts
    93

    resolved [RESOLVED] Horizontal menu, Opera not behaving properly

    My nav menu works as expected in Firefox, but in Opera 9 and IE 7 half of it sits on top of the masthead above. I can get it to behave in IE 7 using conditional comments, but what about Opera? Any ideas?

    Here's the relevant code:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="Content-Style-Type" content="text/css">
    <title></title>
    <style type="text/css">
    body {
      background: #fff;
      color: #444;
      margin: 20px;
      }
    
    #masthead {
      background: #ccc;
      border: 1px solid #444;
      height: 160px;
      }
      
    #nav ul { margin: 0 0 1.5em 0; padding: 0; }
    
    #nav li {
      float: left;
      list-style: none;
      margin: -10px 1px 3em 0;
      }
      
    #nav a {
      margin-right: 1px;
      padding: 10px;
      text-decoration: none;
      }
      
    #nav a:link, #nav a:visited { background: #80bfff; color: #000; }
    </style>
    <!--[if IE]>
    <style type="text/css">
    #nav li { margin: -10px; margin-top: 1px; padding: 10px; }
    </style>
    <![endif]-->
    <title></title>
    </head>
    <body>
    <div id="masthead">
    
    </div>
    <div id="nav">
        <ul>
          <li><a href="#">Page 1</a></li>
          <li><a href="#">Page 2</a></li>
          <li><a href="#">Page 3</a></li>
        </ul>
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    "float" lifts element out of document flow. instead of:

    #nav li { float: left; list-style: none; margin: -10px 1px 3em 0; }

    try:

    #nav li {display:inline; list-style: none; margin: -10px 1px 3em 0; }

    ( <-- too tired to launch OPERA to test this and doesn't have/want to have IE7 yet, at any rate, this is easier to understand )
    Last edited by WebJoel; 03-11-2007 at 06:50 PM.
    I build for: Firefox and tweak for IE

  3. #3
    Join Date
    Dec 2002
    Location
    Göteborg, Sweden
    Posts
    93

    resolved

    Thanks! I tried display:inline, and after playing around with margins and padding, I got it to look the same in Firefox, Opera and IE7 (even without the need of conditional comments).

  4. #4
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    -Isn't that great when it you can get it work in all browsers?
    I build for: Firefox and tweak for IE

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles