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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:04:45+00:00 2026-06-01T08:04:45+00:00

How can I make DIV width 100% (body width) with CSS? Currently, my div

  • 0

How can I make DIV width 100% (body width) with CSS? Currently, my div (.MainHeading) width is set as 100%, but it doesn’t display like 100% when the content width in another div is greater than the screen size. It just displays in top-left corner.

I’ve been searching for the solution for some time but I haven’t found it yet…

This is my CSS:

body 
{
margin:0;
padding:0;
font-family: Verdana, Arial, Helvetica, sans-serif;
}

.MainHeading
{
margin: 0 auto;
background-color:Gray;
background-repeat:repeat-x;
height:auto;
min-height:93px;
width:100%;
}
.Body-Area
{
margin:0 auto;
overflow:visible;
width:950px;
max-width:950px;
height:100%;
min-height:395px;
}
.Container
{
display:table-row;
position:relative;
}
.Mid-Div
{
display:table-cell; 
position:relative;  
padding-left:2%;
padding-right:2%;
float:left; /*for IE 7 & 9 Compatible View*/
overflow-x:auto;/*for IE 8*/
vertical-align:top;
width:100%;
max-width:950px;    
overflow:hidden;
}

And here is my HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <div class="MainHeading">
    </div>
    <div class="Body-Area">
        <div class="Container">
            <div class="Mid-Div">
                 <img align="bottom" width="1224" vspace="1" lang="en"  hspace="1" height="332" border="1" src="images/cover2.png" alt="Test" id="imgtest" dir="ltr" />
            </div>
        </div>  
    </div>
</body>
</html>
  • 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-01T08:04:46+00:00Added an answer on June 1, 2026 at 8:04 am

    I’ve run this code and it seems to be fine. The heading div is 100% of the body, which in turn is the full width of the viewport.

    Update in reply to comment:

    I finally see now. You have a mistaken assumption, which is that the image is expanding the body. In fact, your body remains at 950px, even with min-width, because the image is not expanding it. So the 100% is actually correct.

    The problem isn’t the width setting, it’s the float on your Mid-div. Floating takes it out of layout, so the contents of that div are not pushing the page larger. You have to find a method that eliminates the float. You also have a max-width of 950, so if you want the body to grow, you have to get rid of that. Otherwise the image will simply clip. If clipping the image is acceptable, then perfect. 🙂

    My advice, and I’m sure it sucks to hear this, is to rethink your approach from the ground up. Adding a bit here and a bit there, subtracting something, changing a value… these are going to lead to a mess. The problem you want to solve should be very simple and require not too many rules… write some “requirements” (what must the page do, and under what circumstances) and then rewrite the CSS.

    In any event, here’s a “proof of concept” branch of sandeep’s fiddle without the float; the image is clipped rather than expanding body (due to min-width):

    http://jsfiddle.net/ZMWpW/1/

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

Sidebar

Related Questions

Can anyone tell me how to make a div's background transparent, but with a
The following div's are displayed onclick. How can I make it display a different
With HTML/CSS, how can I make an element that has a width and/or height
How can i make the inner table to overlap the parent div with 5
How can I make a div element move up and down the page when
I can make Firefox not display the ugly dotted focus outlines on links with
I can make a single row IKImageBrowserView by setting the [imageBrowser setContentResizingMask:NSViewWidthSizable]; but in
Can someone tell me how I can make a table be 100% height in
I'm trying to make a CSS fixed width, two column, header and footer layout.
I have a div: clear:both; position:absolute; bottom:0; left:0; background:red; width:100%; height:200px; And a html,

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.