Click here to Skip to main content
11,926,933 members (55,199 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET Scrolling

I have a scrollTop() function in a jquery method that scrolls an element to the desired position based on the mouse movement.

This function always worked perfectly until I decided to remove the height of the element. By removing the height of the element, the element height is determined by the amount of tds (rows) in the element. Before the height was preset to 200px, now it works fine because some elements are 178px and others are 348px in height!

Why won't the scrolltop() function work now though? I am following the scrollTop line with breakpoints and the values are being computed perfectly but the element simply refuses to move down or up.

Thanks a lot,
Posted 21-Apr-13 6:48am
abforce 21-Apr-13 11:54am
please attach some codes that tried with it / explain more with your codes
Jukatzu 21-Apr-13 11:57am
Hi abforce,

info-col used to be the one commented, now its the one beneath it:

/*.info-col { float: left; width: 0px; height: 200px; padding: 0px 0 0 0; overflow:hidden;}*/
.info-col { float: left; width: 0px; padding: 0px 0 0 0; overflow:hidden;}

jquery scrolltop function:

$(".info-col").mousemove(function (mouse) {
$(".info-col").scrollTop((mouse.pageY - $(".info-col").offset().top) * .81);

Thanks a lot for your quick reply. If you need anything else please tell me.
abforce 21-Apr-13 12:04pm
sorry my friend , i cannot figure out the problem, are you want to create a scrollbar for your info-col ??
Jukatzu 21-Apr-13 12:06pm
Yes, the scrolling occurs by getting the mouse Y position and scrolls the element relative to that. Now that used to work fine before I removed the height 200px as you see from above. What isn't it anymore?
abforce 21-Apr-13 12:10pm
if you just want to put a scrollbar to the info-col , you can set overflow:scrollbar in it's css
Jukatzu 21-Apr-13 12:11pm
I know that. Thank you. I just want to find out why removing the height prevents it from working. Thanks again for your help abforce.
abforce 21-Apr-13 12:14pm
if you omit height in css , it initialize with value 'auto' then you cannot have some calculate with this value unless the html element to be in absolute position. ok ?
Jukatzu 21-Apr-13 12:20pm
hmmm I see, so that explains it, great. How can I then make the element height based on the amount of items inside it? Let's say current info-col has 10 items, so height is 200. info-col next to it has 3 items so height needs to be 60 only!

I don't want the element height to be fixed and position has to be relative. Is there a way?
abforce 21-Apr-13 12:24pm
Sorry my dear , i don't know . try by googeling
Jukatzu 21-Apr-13 12:25pm
thank you, your explanation has mattered a lot though ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100