Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

Overlapping divs, scrolling and fragment anchors
 

Mark Tranchant




quote this post edit post

IP Loged report this post

Old Post  07-29-04 - 09:15 AM  
I'm looking for some advice here.

Using a browser that supports fixed positioning (not IE), take a look at:

http://tranchant.plus.com/guitar/chord-tutorial/

The page consists of a fixed header and menu, with scrolling content.
The content goes under the header - in Firefox/Mozilla, and allegedly
Safari, you can see this due to the slight transparency of the header.

I've assigned an appropriate (50px) margin-top to the content so that it
starts below the header when the page is loaded.

OK, now click on the "Chords on the guitar" link in the Contents list.
*If* you have Javascript enabled, your browser should do what you
expect, leaving the appropriate <h2> just below the header bar.

Now reload the page - and notice how the <h2> is at the top of the
viewport, underneath the header bar.

In the first case, some Javascript detects if you're clicking a fragment
link, jumps to it, and then scrolls up 55px to compensate.

Can anyone think of a better way to ensure that links to fragment
anchors, whether from the current page or a different one, are aligned
as I want? I'm after some sort of viewport-margin, but don't want to
resort to assigning a scrollbar to the content div separately.

--
Mark.
http://tranchant.plus.com/


Post Follow-Up to this message ]
Re: Overlapping divs, scrolling and fragment anchors
 

Mark Tranchant




quote this post edit post

IP Loged report this post

Old Post  07-29-04 - 12:15 PM  
Mark Tranchant wrote:

> OK, now click on the "Chords on the guitar" link in the Contents list.
> *If* you have Javascript enabled, your browser should do what you
> expect, leaving the appropriate <h2> just below the header bar.

> ... some Javascript detects if you're clicking a fragment
> link, jumps to it, and then scrolls up 55px to compensate.

Follow-up - this doesn't appear to work in Opera.

--
Mark.


Post Follow-Up to this message ]
Re: Overlapping divs, scrolling and fragment anchors
 

Spartanicus




quote this post edit post

IP Loged report this post

Old Post  07-29-04 - 05:15 PM  
Mark Tranchant <mark@tranchant.plus.com> wrote:

>In the first case, some Javascript detects if you're clicking a fragment
>link, jumps to it, and then scrolls up 55px to compensate.

Ouch, ugly. I once constructed a solution for this problem, from memory:

a[id]{padding-top:55px}

<h2><a id="foobar"></a>Header</h2>

It's been a while since I used it, play with the idea a bit if it
doesn't work immediately.

--
Spartanicus


Post Follow-Up to this message ]
Re: Overlapping divs, scrolling and fragment anchors
 

Christoph Paeper




quote this post edit post

IP Loged report this post

Old Post  07-29-04 - 05:15 PM  
*Spartanicus* <me@privacy.net>:
> Mark Tranchant <mark@tranchant.plus.com> wrote:
> 
>
> a[id]{padding-top:55px}

:target {padding-top: 55px}

Of course that is a CSS3 selector and thus hardly supported yet. On that
site I don't see the reason for that fixed header anyway: most browsers,
that support fixed positioning, do support the 'rel' and 'rev' attributes
of the 'link' element, some even for the 'a' element.

> <h2><a id="foobar"></a>Header</h2>

<h2><a name="foobar"></a>Header</h2>

or rather

<h2><a name="foobar">Header</a></h2>

make sense as does

<h2 id="foobar">Header</h2>

but your code doesn't. Browsers (like NS4) that don't support a target
link to an 'id' in an 'h2' don't support it for 'a' either.

--
"You can only find truth with logic
if you have already found truth without it."
G.K. Chesterton


Post Follow-Up to this message ]
Re: Overlapping divs, scrolling and fragment anchors
 

Spartanicus




quote this post edit post

IP Loged report this post

Old Post  07-29-04 - 05:15 PM  
Christoph Paeper <christoph.paeper@nurfuerspam.de> wrote:
 
>
>   :target {padding-top: 55px}
>
>Of course that is a CSS3 selector and thus hardly supported yet.

Why mention it then?
 
>
>   <h2><a name="foobar"></a>Header</h2>
>
>or rather
>
>   <h2><a name="foobar">Header</a></h2>
>
>make sense as does
>
>   <h2 id="foobar">Header</h2>
>
>but your code doesn't.

A deliberate construct. The reason is that although the padding does not
affect the positioning of adjacent boxes in the vertical stack, the
padded area still exists and since it's higher in the z-index stack it
can obscure content, for example if there's a link located under that
padded area it becomes unclickable.

Demo of this effect that uses the more logical <h2><a
id="foobar">Header</a></h2> construct:
http://www.pan-europe.utvinternet.i...htm#stop_switch
(use a proper browser to see the phenomena)

Scroll down the page a bit, hover over the "RIGHT HANDLEBAR CONTROLS"
link to see the effect.

>Browsers (like NS4) that don't support a target
>link to an 'id' in an 'h2' don't support it for 'a' either.

It's up to the OP if he wants to dumb down his code to support fragment
identifiers that are compatible with NS4. I've stopped doing so some
time ago, I'm sure many have done likewise.

--
Spartanicus


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 03:25 PM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top