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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:48:15+00:00 2026-06-11T10:48:15+00:00

Im trying to make a div which width and height will shrink or expand

  • 0

Im trying to make a div which width and height will shrink or expand proportionally depending on the viewport. As you can see on the example above this method will only make my div expand horizontally but not vertically(fixed height). If I try to give percentages for the height values of my wrapper or main_content, the browser simply ignores the height values unless they are given in pixels or ems. How can I make this work? In my head, if I could just give my div’s height a percentage value this would solve the issue right?

<div class=".wrapper">
  <div id="main_content"></div>
<div>

.wrapper{
   width: 80%;
   margin : 0 auto;
}

#main_content{
  width : 100%;
  height : 500px;
} 
  • 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-11T10:48:16+00:00Added an answer on June 11, 2026 at 10:48 am

    Short answer:

    html, body {
        height: 100%;
    }
    

    Long Answer:

    Your html and body are also containers and they have height that automatically scales with content. Unfortunately, when you set height: 100% in your wrapper, the height is set as 100% of the container, which is automatically the height of your wrapper sans padding and margins. The solution is then to set the height of html to be 100% of its parent, the actual document and then set the height of the body to be 100% of its parent, html. Then your wrapper will be able to be set to a percentage of the height of the document.

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

Sidebar

Related Questions

I'm trying to create a div which will have fixed width and flexible height
I am trying to make my DIV's height expand to it's child elements. I
I'm trying to make a div with a static height and variable width. With
I'm trying to make a simple JQuery button from a div which will change
I'm trying to make hover effect which will change height of li (list) element
I'll keep it brief. I'm trying to make a div element height 100%. All
I'm currently trying to make a button which will take the user back to
I'm trying to make an optional draggable div, which shows up at some condition.
I'm trying to make a sidebar which on a website which will have a
I am trying to make a directory which contains information in a div, some

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.