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

  • Home
  • SEARCH
  • 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 9293081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:02:25+00:00 2026-06-18T21:02:25+00:00

I have the following: <div class=parent> <div class=sizer /> <div class=child /> </div> .sizer

  • 0

I have the following:

<div class="parent">
  <div class="sizer" />
  <div class="child" />
</div>

.sizer {
width: 200px;
}

.child {
position: relative;
width: 400px;
}

I am not allowed to explicitly set the width on the parent, and I am not allowed to set the child to position:absolute.

Using CSS, is there any other way to set the width of .child to 400 without also having the width of .parent expand from 200 to 400?

  • 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-18T21:02:26+00:00Added an answer on June 18, 2026 at 9:02 pm

    If the parent has a set width, then it will not expand with the width of the child, even if the child’s width exceeds that of the parent. See this JS Fiddle example.

    .parent {
        width: 300px;
        height: 50px;
    }
    
    .child {
        width: 400px;
        height: 50px;
        position: relative;
    
    }
    

    enter image description here


    UPDATE

    I am wondering if there is any kind of hack that allows me to do it without setting width on parent

    There is no way to accomplish this without the parent having some sort of width or width-like property. If you are only opposed to using the width property on the parent, you can use several width-like alternatives.

    As cimmanon explained in a comment below, you could set .parent to have a max-width. It does not necessarily have to be 100%; any max-width will do, as long as it is less than the width of the child. See this JS Fiddle example, or check out this code:

    .parent {
        max-width: 200px;
    } 
    
    .child {
       width: 400px;
    } 
    

    Alternatively, you could use position:absolute and set the left and right properties. See this JS Fiddle example, or check out this code:

    .parent {
        position:absolute;
        left:0;
        right:0;
    } 
    

    But remember, these are only two of the many possible alternatives. Hope this helps!

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

Sidebar

Related Questions

I have the following structure: <div class=parent> <div id=child1>Content here</div> <div class=child2>Content here</div> </div>
I have a bunch of elements like the following: <div class=droppableP id=s-NSW style=width:78px; height:63px;
I currently have the following <div class =parent> <div class=inner>Hello <div>Goodbye</div> </div> </div> <div
for example I have the following: I want to go through each div class
I have a webpage including the following div: <div class='book_box'> <table border=0 cellspacing=0> <tr>
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
So I have some html that looks like the following: <div class='something unknown' id='something_unknown_1'>
I have the following html : <div class=mainmenu> <ul class=blue> <li class=><a href=tst/ id=a1_up><span
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have the following ul setup: <div id=sidebar> <ul id=themenu class=sf-menu sf-vertical> <li> <a

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.