views:

209

answers:

6

Compare these 3 URLs (look at the top navigation bar in each case):

  1. http://fast.kirkdesigns.co.uk/blog
  2. as above but with the url fragment #navigation
  3. as above but with the url fragment #node-2655

Note, that the only difference is the URL fragment on the end.

The first two pages display absolutely fine (in Firefox at least). It's the third one where the problem lies. The fragment #node-2655 pushes the top navbar off the top of the screen. When you then scroll back up to the top of the page, the navbar has been cut in half. This happens when using any URL fragment that causes the navbar to be out of the initial viewport when the page is first loaded.

So, how can using a url fragment affect the css layout like this?!

THE SOLUTION: as suggested below, removing the overflow: hidden on the container element that held the navbar fixed the problem. I'd love to understand why though!

+2  A: 

I'd say it's a rendering bug in FireFox as it's fine in Opera. There shouldn't be anyway an anchor would change the CSS like you say (unless you are using jQuery or something).

Dan Diplo
You are right. This does not happen in Opera. That does narrow down the problem, but doesn't fix it. Thanks.ps. the problem persists in Firefox even with js disabled.
Tried FireBug to see if that can narrow down the styles in question? http://getfirebug.com/
Dan Diplo
Yes, I've been firebugging all morning! I thought it may be something todo with the use of height:100% in the <a> in <li><a>, but changing that to absolute heights made no difference.
+1  A: 

I'll just point out that there may be some weird inheritance from the 30+ stylesheets linked to in the head. There may not, either, and it's probably a rendering bug (possibly related to :target styling) that Dan suggested. I just felt it worth pointing out that if you've got more than thirty stylesheets, you likely to start seeing some weirdness, whatever else might happens.

David Thomas
After turning on css aggregation (to combine and minify all the stylesheets) the problem persists. As far as I'm aware, the 30 stylesheet limit is specific to Internet Explorer.
+6  A: 

Remove the overflow:hidden on #main in css_75afd7072eaf4096aaebf60674218e31.css

Emily
Genius!! Can you explain why though?!
ps. I would vote up your answer, but I don't have enough reputation.
A: 

Sorry this isn't an "answer," tho it is a response to the other comments here. This problem is just flabbergasting. It is very easy to isolate (i.e., has nothing to do with number of stylesheets), and doesn't have a proper "solution," as there is no way to achieve the desired rendering.

<!DOCTYPE html>
<html>
<head>
<style>
#container {
  margin: 1em auto;
  width: 40em;
}
#wrapper {
  overflow: hidden;
  position: relative;
}
#c1 {background-color: #aaf;}
#c2 {background-color: #ccf;}
.column {
  float: left;
  margin-bottom: -5678px;
  padding-bottom: 5678px;
  width: 50%;
}
#footer {
  background-color: #eee;
  padding: 1px;
  text-align: center;
}
p {margin: 1em;}
</style>
</head>
<body>
<div id="container">
<div id="wrapper">
<div id="c1" class="column">
<p>This is some content in a short column. We would need some Javascript to change its height if we wanted a different background color for each column to stretch the full height of the respective columns...or we can use large padding together with an equal negative margin.</p>
<ul>
<li><a href="#p1">Jump to P1</a></li>
<li><a href="#p2">Jump to P2</a></li>
<li><a href="#p3">Jump to P3</a></li>
</ul>
</div>
<div id="c2" class="column">
<p id="p1">The desired effect is to have the height of the two columns appear the same. We use 'overflow:hidden' on the containing div (#wrapper) to wrap it around the floated columns.</p>
<p id="p2">These paragraphs have fragment identifiers. Problem comes in when clicking one of the links on the left. Instead of scrolling just the page, the browser scrolls the div with 'overflow:hidden' so the target is at the top. It does this even if the target is already visible.</p>
<p id="p3">Opera does not exhibit this behavior. This occurs in Chrome/Safari, Firefox, and IE. (Interestingly, IE also works as expected if we completely remove the DOCTYPE declaration.)</p>
</div>
</div>
<div id="footer">
<p>Footer stuff.</p>
<p>To see why 'overflow: hidden' (or any other piece of the CSS) is needed, just try disabling it.</p>
</div>
</div>
</body>
</html>
Greg Perham