Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
centering the page horizontally the way this function does vertically?
Old 09-19-2011, 05:19 PM centering the page horizontally the way this function does vertically?
seannarae's Avatar
Skilled Talker

Posts: 65
Location: san francisco, ca
Trades: 0
Code:
$('select').focus(function(){
    var center = $(window).height()/2;
    var top = $(this).offset().top ;
    if (top > center){
       $(window).scrollTop(top-center);
    }
});
The following function accurately centers my page on the vertical axis. Meaning, on a page with large amounts of select-lists, whichever one has focus, the page will be scrolled (centered vertically).

I've tried unsuccessfully to modify this function to do the same thing for the horizontal axis. Meaning: with many select-lists oriented horizontally in a side-scrolling container; whichever select-list has focus, the container would scroll (center horizontally)

Its a syntax issue on my part; i just cant find the way to modify this function (or create a derivative) that also performs the centering on the horizontal axis.

Thanks in advance...
seannarae is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-20-2011, 05:20 AM Re: centering the page horizontally the way this function does vertically?
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
My first thought was that this sounds horrible from a user interface point of view - jerky and disconcerting.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to centering the page horizontally the way this function does vertically?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09623 seconds with 12 queries