Horizontal scrolling website

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
Manak
Forum Newbie
Posts: 2
Joined: Tue Aug 24, 2010 5:22 am

Horizontal scrolling website

Post by Manak »

Hi there,

I was just reading one tutorial one dude made for The Web Squeeze about an
horizontal scrolling website.

http://www.thewebsqueeze.com/web-design ... bsite.html

and the demo:

http://www.thewebsqueeze.com/samples/ho ... jquery-on/

I was wondering if you were able to help me on this:
In the demo, when you click on for example the" BOX 3" link in the menu, it scrolls
till the box3 content is left-aligned to the screen. Do you think it is possible to have it centered on the screen?

thanks! :)


Manuel.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Horizontal scrolling website

Post by pickle »

In that example, centering wouldn't be good, as the previous (box 2) content would still show a bit and the user would have to scan to find the content.

But, not having looked at the code, I imagine what it's doing is finding the left coordinate of box 3 and scrolling the window until the box is to a desired position. All you have to do is change that desired position from being the left of the screen, to a position that would center the box.

The formula you could use would be:

windowWidth/2 - box3width/2 = new left coordinate of box 3
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Manak
Forum Newbie
Posts: 2
Joined: Tue Aug 24, 2010 5:22 am

Re: Horizontal scrolling website

Post by Manak »

Oh thank you so much! :)
Post Reply