My goal is to ensure that my website perfectly matches the height of the screen, even though there is not a lot of content

To be more specific, I am looking to have the content section (the section with the white background) fill the remaining space on the page so that the header and footer maintain their fixed sizes while the content section expands to fit the full height of the viewport.

Here is the HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>Home - Painter Master Gen</title>
        <link rel="stylesheet" href="css/index.css">
        <script src="js/script.js"></script>
        <link rel="shortcut icon" type="image/png" href="img/favicon.ico">
        <meta http-equiv="Content-Language" content="en">
        <meta http-equiv="last-modified" content="21.10.2018 08:22:20">
        <meta charset="UTF-8">
        <meta name="author" content="Til Jungbluth">
        <meta name="description" content="This is where a description will go...">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div id="wrapper">
            <div id="headerWrapper">
                <header id="header">
                    <a href="index.html"><img id="headerLogo" src="img/Logo Painter Guild.jpg" alt=""></a>
                    <h1 id="headerHeading">Painter Master Gen</h1>
                    <p id="headerSlogan"><span id="design">Design</span> - <span id="beauty">Beauty</span> - <span id="protection">Protection</span></p>
                </header>
                <nav id="headerNav">
                    <a href="index.html" class="headerNavLinks" id="headerNavLinkActive">Home</a>
                    <a href="our_team.html" class="headerNavLinks">Our Team</a>
                    <a href="contact.html" class="headerNavLinks">Contact</a>
                </nav>
            </div>
            <div id="contentWrapper">
                <h2 id="contentHeading">Lorem ipsum dolor sit amet</h2>
                <div id="content">
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
                    ...
                </div>
            </div>
            <footer id="footer">
                <p id="footerP">© Painter Master Gen GmbH | 
                    <a href="contact.html" class="footerNavLinks">Contact</a> | 
                    <a href="imprint.html" class="footerNavLinks">Imprint</a>
                </p>
                <button onclick="topFunction()" id="scrollBackToTop" title="Go to top">Back To Top</button>
            </footer>
        </div>
    </body>
</html>

This is the corresponding CSS:

... (CSS code omitted for brevity)

Answer №1

section {
  min-height: 100vh; // ensures the section occupies at least the full height of the viewport.
  overflow-y:auto; // enables vertical scrolling when content exceeds the screen height.
}

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

What is the best way to center CSS content such as boxes and text?

As a beginner in CSS tutorials, I am seeking guidance on how to center the entire content in the browser. Below is the CSS code that needs attention. Additionally, there is a screenshot of the current output included for reference. body { background:#E9 ...

The absence of the pyramid in the WEB GL canvas is noticeable

I encountered an issue while attempting to generate two shapes on the canvas: an octagon and a pyramid. The octagon displays correctly, but the pyramid does not appear as expected. Below is the code snippet related to the creation of the pyramid: pyramidP ...

How to Align Horizontal Scrollable Cards in Bootstrap 4

Having trouble centering a Single Row of Horizontal Scrolling Cards. I've tried: a) the mx-auto class b) using text-align: center Nothing seems to be working and there's a lot of space on the right side in desktop view. Interestingly, the scro ...

Leverage the Google Drive API for the storage of app-specific data

I'm currently developing a JavaScript application that runs on the client side and need to store a JSON object containing configuration details in a Google Drive Appdata file. Through the Google Drive API, I can successfully check for the file within ...

Setting the opacity of an image will also make the absolute div transparent

I currently have an image gallery set up with the following structure : <div class="gallery"> <div class="message"> Welcome to the gallery </div> <img src="http://placehold.it/300x300" /> </div> Here ...

Creating transparent overlay boxes with CSS grid

I'm working on a design where I need to display text information over an image. The challenge is aligning the text properly, especially when the screen size changes due to using a grid system (1140). Currently, I have a div with transparent background ...

Raycasting in Three.js originating from the mouse's position

In the process of developing an application using three.js and jQuery, I am implementing raycasting to place a helper at the point where the ray hits. My goal is to achieve a similar result as shown here. While I have successfully achieved this functional ...

JavaScript: Use onclick events to change the class of a div on multiple divs

I have a jQuery script that allows for toggling of the parent class when #icon is clicked. Additionally, when the body is clicked, it reverts back to the original class. Now, I'm looking to achieve the same behavior when clicking on #item5 or #item4 a ...

A div housing a jQuery progress bar within an unordered list (ul)

Having an issue incorporating a jQuery progress bar into a ul li tag. <ul> <li> <a href="test">test</a> <div id="progressbar"></div> </li> </ul> I have set display: block for the anchor tag and ...

The left margin of the Bootstrap 12 column grid is not aligned correctly

Currently, I am utilizing Bootstrap in conjunction with Vue within an App.vue file. One issue I have encountered is the excessive empty space on both the left and right sides when using Bootstrap. An image has been provided below for reference. I followed ...

PHP: Invoking a function within the HTML content of a variable

I need help with adding a PHP function to a variable storing HTML code for a form. This is what the current setup looks like: <?php function example_function() { // code } $form = ' <form action" <!-- etc. --> > <input <!-- etc ...

The CSS property object-fit: cover is unable to properly display JPEG images with EXIF orientation greater than 1

I'm having trouble with my Angular app and creating a gallery of photos from my Samsung Galaxy. I am using the "object-fit: cover" css attribute for a nice design, but it only seems to work correctly when the image has an EXIF "orientation" property e ...

Tips for choosing classes with identical names without resorting to incremental IDs

https://i.stack.imgur.com/EVQVF.pngAre there alternative methods to select classes with the same name but in different table rows? Currently, I am using html class="className + id" and then in jquery to select $('.className'+id)... some code. Is ...

What is the best way to create an oval-shaped background for a div element?

Can someone help me achieve an oval shape for my index page div? I tried using border-radius but the edges are too round for my liking. I am looking for a more specific result See the CSS code below for reference <div class="home-page"></div> ...

Using the radius to determine the center point of the circle

<span class="qs">Q{{i + 1}} <a href="#question-view"></a></span> <div class="tooltipp text-center bubble[ngStyle]="bubbleStyle(prof?.proficiencyBrightness, prof?.proficiencyRadius)"> </div> In the illustration below, ...

Display each div one at a time

I am working on a script that should reveal my divs step by step. However, the current code only shows all the divs at once when clicked. How can I modify it to detect each individual div and unveil them one by one? For example, on the 1st click => expa ...

Tips for avoiding flickering in a background image when it is being changed

Utilizing JavaScript, I am setting a repeated background image from a canvas to a div in the following way: var img_canvas = document.createElement('canvas'); img_canvas.width = 16; img_canvas.height = 16; img_canvas.getContext('2d' ...

Incorporating Javascript jQuery functionalities from an external file

I have encountered an issue when trying to run my index.html file with the control.js file that I outsourced. It seems like they are not working together properly: <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.c ...

Managing data from POST requests in Angular using Typescript

I have implemented a simple function in my component TypeScript file to send a post request and retrieve data from a server. The function is working correctly, but I am facing an issue when trying to assign the array of data to a variable named 'json& ...

Loading elements of a webpage in a consecutive order

I am currently working on implementing a content slider within my Django application. The specific slider that I am using can be found at this link. One challenge that I am facing is the need to load close to one hundred 'contentDiv' pages, and I ...