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 6942657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:03:10+00:00 2026-05-27T13:03:10+00:00

I have div which height changes depending on its content. Div element is located

  • 0

I have div which height changes depending on its content. Div element is located at bottom outside of the screen but when user clicks a button, div element will come up exactly the height of the div. For example, if div’s height is 200 pixels, it will move up 200 pixels and if div’s height is 400 pixels, it will move up 400 pixels. I’m able to get the height of the div and lift the div element up but I’m unable to move it back outside the screen. Here’s my code:

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#button {
    height: 100px;
    width: 100px;
    background: blue;
}
#box {
    position: absolute;
    top: 100%;
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: all 1s ease-out;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
function moveUp() {
    var height = $("#box").height();
    $("#box").css('-webkit-transform', 'translate3d(0px,-'+height+'px,0)');
}
function moveDown() {
    var height = $("#box").height();
    $("#box").css('-webkit-transform', 'translate3d(0px,'+height+'px,0)');
}
</script>
</head>
<body>          
    <div id="button" onclick="moveUp();"></div>
    <div id="box" onclick="moveDown();"></div>
</body>
</html>

I would also like to have an option that I would be able to lift up and put down the box by clicking the same button. So, two solutions needed 🙂

  • 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-05-27T13:03:11+00:00Added an answer on May 27, 2026 at 1:03 pm

    Try this fiddle: http://jsfiddle.net/W7NDp/2/

    Script:

    var visible = false;
    function moveUp() {
        if(visible)
        {
            moveDown();
        }
        else
        {
            var height = $("#box").height();
            $("#box").css('-webkit-transform', 'translate3d(0px,-'+height+'px,0)');
        }
        visible = !visible;
    }
    function moveDown() {
        var height = $("#box").height();
        $("#box").css('-webkit-transform', 'translate3d(0px,0px,0)');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a link which animates some div 's height when its hovered, but
I would like to have a div which changes its content on the page
Sample page On the sample page I have set div#content { padding-bottom:20px; } which
Hi I have a simple sidebar inside a div which has height:100% and I
I have a div which contains number of elements which user can drag and
I am using multiple instances of div class .item_wrap, which changes height when the
I have four div s which are animated using size, height and positions; that
I have a div,which content some text content. <div id=con style=position:absolute;left:50px;top:50px;border:1px solid red;font-size:12px;> Text
I have a div which I have attached an onclick event to. in this
I have a div which displays the current value of the slider and the

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.