What is preventing the container from occupying the full height?

Currently, I am working on creating a survey form page. I have successfully created a div with the id "container" which holds all the elements on my site. For the code snippet and reference, you can check out this link

CODE

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  color: #black;
  background-color: #202020;
}

#container {
  height: 100%;
  max-width: 650px;
  margin: 0 auto;
  background-color: #fff;
}
<div id="container">
  <header id="title">
    <h1>Software World</h1>
    <p id="Description">Entertainment which creates software for people</p>
  </header>
  
  ... (survey form HTML code here) ...
      
</div>

I am facing an issue where the container does not take the full height of the webpage as expected. You can see the problem in this picture

I aim to have the container always fill the entirety of the website's height, even when it is in fullscreen mode. It should consistently maintain its full height regardless of the screen size.

enter code here

Answer №1

To solve the issue, simply remove the min-height:100vh; property.

Answer №2

Opt for using height: auto instead of height: 100%;. While height: 100% takes up the entire viewport, it does not account for content height. In contrast, height: auto flexibly adjusts to accommodate all content.

Answer №3

You might want to consider deleting the height:100%; from the html tag

Answer №4

Give this a shot.

body {
  color: #black;
  background-color: #202020;
}

#container {
  height: 100%;
  max-width: 650px;
  margin: 0 auto;
  background-color: #fff;
}

The issue may have been setting the styling for html,body. In this scenario, it is sufficient to only set the background-color for the body of your webpage.

PRO TIP: Avoid using IDs for styling purposes. IDs are typically used in JavaScript or other programming languages. Instead, utilize classes for styling.

Answer №5

Here's another way to achieve the same result:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html,
body {
    color: #black;
    background-color: #202020;
}
.input-div{
    background-color: #fff;
}
#container {
    height: 100vh;
    max-width: 650px;
    margin: 0 auto;
    background-color: #fff;
}
<div id="container">
  <header id="title">
    <h1>Software World</h1>
    <p id="Description">Entertainment which creates software for people</p>
  </header>
  <form action="send_it_somewhere.html" id="survey-form" method="POST">
    <div class="input-div">
      <label for="name" id="name">Name</label>
      <input type="text" id="name" name="name" required>
    </div>
    <div class="input-div">
      <label for="email" id="email">E-mail</label>
      <input type="email" id-"email" name="email" required>
    </div>
    <div class="input-div">
      <label for="age" id="age">Age</label>
      <input type="number" id="age" name="age" min="1" max="100">
    </div>
    <div class="input-div">
      <label for="dropdown">How do you want to pay</label>
      <p>(Hold ctrl and click to tick multiple)</p>
      <select name="dropdown" id="dropdown">
        <option value="all">All at once</option>
        <option value="months12">12 months</option>
        <option value="months6">6 months</option>
        <option value="Other">Other</option>
      </select>
    </div>
    <div class="input-div">
      Gender
      <div>
        <label for="male">Male</label>
        <input type="radio" name="gender" id="male" value="male">
        <label for="female">Female</label>
        <input type="radio" name="gender" id="female" value="female">
      </div>
    </div>
    <div class="input-div">
      <p>What would you like to have in your software</p>
      <label for="pc_system">Access on PC</label>
      <input type="checkbox" name="pc_system" id="pc_system" value="pc_system">
      <div class="blank-div"></div>
      <label for="android-system">Access on Android</label>
      <input type="checkbox" name="android-system" id="android-system" value="android-system">
      <div class="blank-div"></div>
      <label for="ios-system">Access on IOS</label>
      <input type="checkbox" name="ios-system" id="io-system" value="ios-system">
      <div class="blank-div"></div>
      <label for="online_mode">Online Mode</label>
      <input type="checkbox" name="online_mode" id="online_mode" value="online_mode">
      <div class="blank-div"></div>
      <label for="payment">Payment</label>
      <input type="checkbox" name="payment" id="payment" value="payment">
      <div class="blank-div"></div>
      <label for="making_accounts">Option of making accounts</label>
      <input type="checkbox" name="making_accounts" id="making_accounts" value="making_accounts">
      <div class="blank-div"></div>
      <label for="support">24/7 Support</label>
      <input type="checkbox" name="support" id="support" value="support">
      <div class="blank-div"></div>
    </div>
    
    <div class="input-div">
      <label for="question">Ask a question</label>
      <textarea name="question" id="question"></textarea>
    </div>
  

I made some changes by removing the height from the body and adding a height using vh on the container instead. This allows for better flexibility when adding more content. Additionally, I noticed that the 'input-div' div was not inside the 'container' div, so I made sure to adjust this for a more cohesive layout.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Elements on the page appear and disappear as you scroll down

Whenever my scroll reaches the bottom of element B, I want my hidden sticky element to appear. And when I scroll back up to the top of element B, the sticky element should be hidden again. Here are my codes: https://i.sstatic.net/J49dT.jpg HTML <htm ...

The actions performed within an event listener function are undone once they have been carried out

I'm a newcomer to Javascript and I am currently experimenting with it. While browsing through a tutorial on w3schools, I came across an example of changing the color of a button after clicking on it. My idea was to take it a step further by loading a ...

Selenium: Utilizing the get_attribute() function with a CSS query

I am attempting to retrieve the value of the title attribute. There are multiple links on the page and I need to specifically select the first link and extract its title attribute. Here is the selenium command that I have used: self.se.get_attribute("c ...

Altering the hover functionality for dynamically created class elements

I have a vision to create a unique e-commerce storefront with tile design, featuring an item thumbnail that reveals the item name upon hovering. I found inspiration from this example, but I want the item name to slide up smoothly on hover, rather than simp ...

Tips for enlarging an image element without causing the header to expand

I'm looking to enhance a logo image within a header element by expanding it on hover or creating a pulse effect. I thought of increasing the max-width and adding a transition for simplicity. However, my main concern is how to make only the img element ...

What steps are necessary to alter the background color of a jumbotron?

Can someone help me figure out how to change the background-color of the 'jumbotron' class in Bootstrap? The default color set in bootstrap.css is #eee. I've tried various methods like replacing it with none, none !important, or transparent ...

Changing the order on mobile devices in Bootstrap 4: A quick guide

Currently, I am working on a responsive layout using Bootstrap 4 with two columns. Each column contains a total of 9 divs - four in the first column and five in the second column. My goal is to rearrange the order of the divs within the columns when the vi ...

The Foolish Mistake: Undetermined Dollar Sign

Can someone please help me with this issue? I've searched everywhere but I can't seem to fix the "Uncaught ReferenceError: $ is not defined" error. I have rearranged my script, tried putting it at the bottom, but nothing seems to work. Any sugges ...

How can I remove the text from a drop down menu?

Currently, I am attempting to create a text field with a drop-down menu. However, I want to restrict the user from typing in the text box and only allow them to select options from the drop-down menu. I have tried using disable and readonly, but they are n ...

What is the best way to execute a Java program from a PHP webpage after submitting a form?

I have a .php page where I am trying to run a Java program in the backend after submitting a form. I have attempted using exec() and system() functions, but unfortunately it is not working as expected. Can someone please provide assistance with this issue? ...

What steps should be taken to create this specific layout using Vue-Bootstrap?

Currently tackling a web project and aiming to design two rows that resemble the following layout: https://i.sstatic.net/tLv1h.png Details of the screenshot (such as icons) are not necessary, but rather focusing on the arrangement of aligning two rows bes ...

How to set a specific text color when hovering over a link with jQuery

Seeking assistance in customizing a hover effect for spans within links. The current code applies the effect to all links with spans, rather than just the hovered item. Any tips on refining the code to target specific elements would be highly valued. $( ...

Center alignment within input-group-prepend using Bootstrap 4

Is there a way to create a fixed width input-group-prepend that is larger than its content, while still keeping the content centered horizontally? I've experimented with text-center and align-items-center, but the content always ends up left aligned. ...

Position divs to align text beside icons

I am currently working on a Bootstrap popover to display various pieces of information, each containing an icon and some text. Additionally, I am incorporating twig into this project. Here is the HTML structure: <span class="fa fa-user instructor-con ...

How can I showcase a different component within another *ngFor loop?

I am currently working on a table in HTML that displays product information. Here is the code snippet for it: <form [formGroup]="myform" (ngSubmit)="submit()" > <tbody> <tr class="group" *ngFor="let item of products;"&g ...

Trouble Aligning HTML Button to the Right

I'm currently working with this HTML code. My goal is to have the "Get Geotag" button aligned to the right side, with the text positioned anywhere to the left or above the button. However, I'm struggling to properly align the buttons and maintain ...

Tips for adjusting the number of columns in a list display using CSS

Recently, I decided to delve into the world of CSS and Bootstrap. I came across an interesting example that I'm trying to implement in my project. You can find the example here. Here's the HTML code snippet: <div class="container"&g ...

Issues encountered in loading JavaScript with jQuery script

I am facing an issue with my jQuery script not loading correctly. When I click on the calculate button, nothing happens as expected. I made sure to copy and paste jQuery directly into the file for offline use, and also created a personal console due to res ...

Tips for adjusting the icon size within the <IconContext.Provider> dynamically

Currently, I am using the 'IconContext.Provider' tag to style my icons from the 'react-icons' library. Are there any solutions available to dynamically change the size of the icon based on the size of my media? Is using the global styl ...

Is there a way to customize the dot in a JavaFx RadioButton?

Hello fellow coding enthusiasts, I am looking to find out how I can customize the color of a RadioButton dot. I want to have 3 RadioButtons, each with a different color to represent a state. Do I need to use CSS for this task? If so, could someone please ...