Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:03:11+00:00 2026-06-13T12:03:11+00:00

I want to make an scrollable div that scrolls down when the user hovers

  • 0

I want to make an scrollable div that scrolls down when the user hovers another div. The content inside the scrollable div will change (it’s gonna be only text) so I can’t set up an absolute height value for that DIV, this is why div’s height is ‘auto’.

I have come into a solution that works when I set up an absolut height value on ‘.post-right’ div’s CSS, but it returns no value if div’s height is ‘auto’ just I like I need it to be.

I’ve tried putting jQuery block of code on the (document).ready function as well, result is exactly the same.

Any ideas? Thank’s in advance.

HTML CODE:

<div class="post-right-cont">
    <div class="post-right">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut aliquam libero ut nisi consectetur pretium. Donec auctor auctor mauris, in tempor mauris blandit et. Aliquam nibh felis, tincidunt a auctor vel, feugiat at enim. Duis faucibus porta mi ut fringilla. Pellentesque eleifend erat a tellus aliquam sodales. Nullam lorem tellus, accumsan quis laoreet id, luctus et urna. Curabitur eleifend tellus non orci ullamcorper adipiscing. Integer est tellus, bibendum at ultricies a, viverra at orci. Curabitur porta tincidunt nunc, at placerat ipsum malesuada et. Vivamus et est purus, id suscipit tortor. Curabitur turpis metus, dapibus et consectetur non, tincidunt in est. Vestibulum nisl libero, sodales sit amet auctor eu, congue at velit. Vivamus et erat massa, nec viverra risus. Fusce iaculis dolor vel augue ornare accumsan.<br/><br/>

    Quisque a metus arcu. Suspendisse hendrerit commodo justo in sagittis. Phasellus a scelerisque quam. Fusce lacinia lacinia justo. Duis id hendrerit enim. Sed eleifend eros et turpis rutrum consectetur. Maecenas pulvinar volutpat odio, non imperdiet augue pretium quis. Proin rutrum, est vitae auctor dapibus, diam dolor rutrum libero, sed feugiat metus turpis sed mauris. Sed eleifend dolor arcu. Cras laoreet nibh convallis magna congue sit amet consequat tortor porttitor. Duis et mauris non lorem consectetur luctus. Aliquam mollis sem sit amet tortor iaculis egestas. Duis tincidunt pellentesque leo, nec vulputate turpis dapibus sit amet. Aliquam rhoncus luctus orci, et aliquet eros porttitor in. Etiam arcu eros, viverra tristique tincidunt vel, facilisis et mauris.<br/><br/>

        Morbi congue auctor luctus. Sed nisl dui, varius id ornare et, tincidunt sit amet enim. Aliquam egestas ultricies nisl, id condimentum erat fermentum quis. Morbi lectus nunc, aliquam volutpat egestas quis, iaculis a nulla. Pellentesque fermentum mauris at libero pulvinar viverra. Aliquam a ante orci, a luctus purus. Vivamus ut est ut mauris pulvinar mattis ac et magna. Aenean congue dictum lectus at suscipit. Suspendisse interdum, erat pulvinar gravida vulputate, mi mauris feugiat justo, at euismod augue sapien eu sapien. Praesent at quam purus. In hac habitasse platea dictumst. Fusce vel tellus a massa tempor volutpat a at magna. In eu enim odio. Quisque bibendum tortor est. Phasellus a scelerisque quam. Fusce lacinia lacinia justo. Duis id hendrerit enim. Sed eleifend eros et turpis rutrum consectetur. Maecenas pulvinar volutpat odio, non imperdiet augue pretium quis. Proin rutrum, est vitae auctor dapibus, diam dolor rutrum libero, sed feugiat metus turpis sed mauris. Sed eleifend dolor arcu.
    </div>
    <div class="scroll-down"></div>
    <div class="scroll-up"></div>
</div>

CSS:

.post-right-cont {
    width: 540px;
    height: auto;
    overflow: hidden;
    position: relative;
}

.post-right {
    position: absolute;
    top: 0;
    left: 20px;
    height: auto;
    width: 480px;
    padding-top: 40px;
}

jQuery:

$(window).load(function() {
// SCROLL POST

            // EDIT - post-right-cont height was set up before. I just past it here now.
    var wHeight = $(window).height();
            $('.post-right-cont').css('height', wHeight - 36);

    if ($('div.post-right').height() > $('.post-right-cont').height()) {

        $('div.scroll-down').hover(function() {animateContent('down');}, function() {
            $('div.post-right').stop();
        });

        $('div.scroll-up').hover(function() {animateContent('up');}, function() {
            $('div.post-right').stop(); 
        });
    }

    function animateContent(direction) {

        var containerHeight =  $('.post-right-cont').height();

        var textHeight = $('div.post-right').height();

        var animationOffset = textHeight - containerHeight;

        if (direction == "up") {
            animationOffset = 0;
        }

        $('div.post-right').animate({"top" : -animationOffset + "px" }, 8500);

    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:03:12+00:00Added an answer on June 13, 2026 at 12:03 pm

    $('.post-right-cont').height() will return a value 0 because you have wrapped just one item inside, which have absolute positioning, so the absolute positioned element will not increase the size of .post-right-cont. So jQuery returns the correct value – 0. The height of .post-right will not increase the height of .post-right-cont because absolute positioned elements do not increase the height or width of their wrapping tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have only one list div and I want to make it scrollable. I
I want to make my QML Grid scrollable as soon as the content is
Does anyone know of a JQuery plugin that could make any <div> scrollable? I
I want to make my view scrollable, my view contains childs layouts inside linear
I want make interactive application where user launches it and can do various task
I have style sheet with a class name changebackgroundcolor i want make change in
How to make the jList selectable and jScrollPane scrollable inside a jTable. This is
There are so many columns on my Telerik RadGrid that I want to make
I want to make my TextBlock scrollable but I can't make it work. Maybe
I want a scrollable ( overflow: auto ) div element to be completely contained

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.