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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:41:36+00:00 2026-05-18T21:41:36+00:00

How can I make a child div the width of the parent div when

  • 0

How can I make a child div the width of the parent div when the child has position:absolute and some padding?

Here’s the example. I want the child to not extend past the parent.

http://jsfiddle.net/usv9R/

  • 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-18T21:41:37+00:00Added an answer on May 18, 2026 at 9:41 pm

    http://jsfiddle.net/usv9R/1/

    If you manually set top/left/right/bottom, without setting the width explicitly, it will expand to the parent. I’ve set this to 12px for all which gives the padding effect

    Note the position:relative; on the parent, otherwise the child will be absolute to the parent’s parent and so on.

    This has one unfortunately consequences. One, which you may already be aware of, the parent won’t expand to fit the child.

    Also, it just occurred to me that you maybe wanted the padding on the child instead? You can do that just fine, but be forewarned that given the above limitation, the parent won’t necessarily encompass the child with too much vertical padding.

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

Sidebar

Related Questions

How can I make a div container expand its width to contain all its
<div id=wrapper style=background:red;> <div id=child style=height:500px;float:left;></div> </div> How can I make #wrapper stretch with
If I have this: <div id='parent'> <p>Parent stuff here</p> <div id='child'>Child stuff here</div> </div>
How can I make this link use the child selector without changing or removing
I can make Firefox not display the ugly dotted focus outlines on links with
In C# you can make a block inside of a method that is not
I've got a parent div floated left, with two child div s that I
I have two paragraphs wrapped in a div. I want to make the first
Here's a page with some thumbnails: http://thenozzle.net/games What I want is when you hove
I have a div with a certain width and within this parent div I

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.