tags:

views:

102

answers:

3

I'm facing a problem that's really strange. It's in every browser.

Everything is working correctly, until you try to go to a section using the hash ( like #contactUs in my page)... try this url : http://mahersalam.co.cc/projects/2011/#contactUs

You will see that the page SHIFTS 10px to the top. if you take off the hash, it works again.

I have a wrapper on the page (#container) that has overflow:hidden, I did it to make sure no scroll bars appear if the resolution change. If you remove the overflow property it works too.

I guess the shifting happens through the place of the scroll bar, but because it's hidden it's place only stays.

So does anyone knows how to fix this problem ?

Edit :

I found the solution and I wrote it down in the anwsers.

+1  A: 

That sure is an aesthetically pleasing layout. Very nice.

Anywho, the overflow seems to be taking a chunk out of #headerWrap's top margin, and adding it to the bottom of the page for me, it's exactly 16 pixels.

Nothing I've tried, so far, has worked. Can you get it so that #container does not overflow horizontally?


Edit: Never mind; the following does not work...
Changing #container's style from overflow: hidden; to overflow-y: hidden; seems to work on Firefox is not a very robust solution.

Brock Adams
Thank you both for your kind words. @Brock: I tried to stop the page from overflowing when clicking, but I don't know what exactly is overflowing. It's not only the #headerWrap. It's a strange problem... I designed several layouts before but this time this problem is happening for no reason.Do you have any suggestions that will fix the problem, or even stopping it from it's root ?Thanks again.
Maher4Ever
It *looks* like the footer, `leftCol` and `rightCol` are causing the horizontal overflow. Killing the margin|padding-left|right seems like an avenue worth pursuing. But then `#footerWrap` still overflows for some reason. Giving it a max width around 75em, might help.
Brock Adams
@Brock: Thank you for your help and time. After more tests It seems that taking the height:100% from leftCol and rightCol fixes the problem. I admit it's strange because this is only happening when the url is clicked. Anyhow thanks a lot.
Maher4Ever
@Maher: Nice you solved it, but you should write your own answer now and mark it as 'correct' by clicking the check mark when possible (>48h or something). This way we can see that your question got properly answered and doesn't need anyone's attention anymore (*and* provides a solution to someone else who might get the same problem in the future). BTW, nice to see someone from my own country! :)
Marcel Korpel
@Marcel: I just added the answer and I will accept it within 2 days.bedankt ^^
Maher4Ever
+1  A: 

I believe the problem is that the fragment identifier causes the container to scroll before the page scrolls. After the page is complete the container element has a scrollTop value of "16".

Here's what I did in greasemonkey in Firefox to recover the missing area.

window.addEventListener('scroll', 
  function(e)
  { 
    var cont = document.getElementById("container");
    if ( cont.scrollTop > 0) cont.scrollTop = 0; 
  }, 
  false );

What that, when you scroll back to the top, the missing space is shown.

As a solution, I don't like it at all, but it demonstrates where your problem lies and maybe others can think of a cleaner way of fixing the container's scrollTop to 0.

Alohci
If I get this right, this means that there is an error in the way the browsers are handling this kind of situations, correct ?
Maher4Ever
@Maher4Ever - I don't know of any spec that actually covers how browser scrolling is distributed when the target of a fragment identifier is inside nested scrollable elements. However, it seems that there is, in fact consensus among the browser makers, so I guess we have to consider it a feature rather than a bug.
Alohci
A: 

The solution was to remove the height:100% from the .rightCol and .leftCol .

I guess that these sections were overflowing because of the height property.

Maher4Ever