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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:56:39+00:00 2026-06-07T17:56:39+00:00

When my browser window is maxmised this code works fine, the child is contained

  • 0

When my browser window is maxmised this code works fine, the child is contained within the parent and the parent spans the width of the browser. However, when the browser window is smaller than the child elements width, the parent element fails to contain it (tested in chrome 20 and firefox 13)

http://jsfiddle.net/x9duU/

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Example</title>

        <style type="text/css">
            #toolbar {
                background-color:#cccccc;
                padding:10px 0;
            }

            #nav {
                background-color:#00cccc;
                margin:0 auto;
                width:1000px;
            }
        </style>
    </head>
    <body>

        <div id="toolbar">
            <div id="nav">NAVIGATION</div>
        </div>

    </body>
</html>

I can solve the problem by floating the parent and giving it a minimum with of 100% but this seems wrong. What can I do to solve this?

  • 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-07T17:56:40+00:00Added an answer on June 7, 2026 at 5:56 pm

    #toolbar is a blocklevel-element, which defaults to width:100% – 100% width regarding the parent element. This is the rule it obeys to, letting the child overflow in case it’s width exceeds. You could tweak this by setting the overflow property.

    However, if you want the parent div to take it’s child’s width into account set a min-width (which equals the width of the child) Important: you have to take possible margins and paddings into account (or change the box-model to border-box).

    #toolbar {
       min-width:1000px;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need the width of the Chrome browser window and my current code is:
I have a child browser window (aspx) opened from the parent application. The child
When I reduce the width of my browser window, select elements within the fieldset
When I resize my browser window and make it smaller, the navbar nicely creates
Possible Duplicate: Open child browser window from child window I have a list of
I wanna get the width of browser window. It should contain the width of
I create a secondary browser window with Javascript code, using the window.open function, and
How can a browser window know if it is a parent window or a
When you create a new browser window, you pass it a name like this:
I have a chat in a popup browser window. This chat page (ASP) checks

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.