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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:49:27+00:00 2026-05-24T18:49:27+00:00

I have a container that does not have any set dimensions. I want the

  • 0

I have a container that does not have any set dimensions. I want the size of the container to be driven by it’s contents. Like so:

    #containerTL{
    position:absolute;
    bottom: 0px;
    right: 0px;
    margin: 5px;
    border: 1px solid black;
    cursor: default;    
    }

    #content{
    position:relative;
    background: gray;
    margin: 0px;
    top: 0px;
    height: 100px;
    width: 120px;
    cursor: default;    
    }

    <div id="containerTL"><div id="content"></div></div>

I also want to move the position of the container and have it’s contents come along for the ride. Setting the position by modifying the containers style.top & style.left is easy, the problem I have is that the elements may be positioned using “bottom” or “right”. Without set dimensions, the container grows, rather than move when I set the top and left properties.

I think I understand the problem. Lets say the style specifies a bottom and left position, and I update the top and left properties using javascript, the top and left properties get set, but the style specifies a bottom property.

I suppose I could always set the bottom and right properties to “auto” once I update top and left… but what if I wanted to be able to send each element back to it’s original position, generically, without writing a special case for each element.

Here’s a fiddle to illustrate the problem: fiddle

  • 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-24T18:49:28+00:00Added an answer on May 24, 2026 at 6:49 pm

    You can do:

    this.style.right = '';
    this.style.left = '';
    this.style.top = '';
    this.style.bottom = '';
    

    and it will unset anything you set via .style and revert back to what you defined in the stylesheet.

    See this fiddle for an example. Clicking once moves it, clicking again should move it back to the original position.

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

Sidebar

Related Questions

I have a container element that you can drag objects around in. I want
I have a div that I want to set to 90% of its parent
I have a container that contains an image that I need to drag from
I have a container div that holds two internal divs; both should take 100%
i have a container box that includes a number of thumbnails. i earlier made
I have a container MovieClip that serves as a content area that I need
I have a UIView container that has two UIImageView s inside it, one partially
I have an animation on a partially hidden div container that will execute when
I have a MDI container form, and some child forms that update their title
I have a dynamic class that serves as a storage container for configuration settings.

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.