Create a decorative division containing a border that extends all the way down to the top of the sticky

(Not to be found anywhere else on the internet to my knowledge, I've been searching for almost two days without success.)

I am facing an issue where a content div with a semi-transparent background and decorative border underneath the site logo does not extend down to meet the top portion of the footer. The footer is fixed to the bottom of the page using position absolute. This problematic area is on the Contact page, which has just a few lines of text and a basic contact form, resulting in insufficient content to fill the entire page.

My specific requirement is for the bordered div to cover the whole page without generating a vertical scroll bar and align seamlessly with the top of the absolutely positioned footer.

The rest of the website manages to push the footer down sufficiently due to ample content. Hence, any CSS properties can be used here, including resorting to a table hack if necessary!

JS Fiddle

header {
                height: 44px;
                background: orange;
            }
            
            article {
                box-sizing: border-box;
                border: 1px solid red; 
            }
            
            footer {
                height: 22px;
                background: green;
                position: absolute;
                bottom: 0;
            }
<body>
<header>
header
</header>
<article>
article with small amount of content<br>
<br>
and a simple contact form<br>
<br>
this red border needs to meet the top of the footer<br>
without creating a vertical scroll bar
</article>
<footer>
footer
</footer>
</body>

Answer №1

If you want to adjust the height of your "article" using CSS3, you can set it to be 100% minus the combined heights of the header and footer elements (in this case, 66px) like so:

height:calc(100% - 66px);

Just make sure that all parent elements of the article have their heights set to 100% as well, including html and body.

Check out the updated version on JSFiddle

Answer №2

Here is an alternative solution that utilizes the position fixed property. While I believe Alvaro Menendez's answer may be superior, this approach also achieves the desired result.

article {
  box-sizing: border-box;
  border: 1px solid red; 
  position:fixed;
  top:50px; /* size of header */
  right:0;
  bottom:30px; /* size of footer */
  left:0;
}

Click here for a demo of the code in action

Answer №3

To achieve your basic layout easily, you have the option to use either display:table or display:flex.

Here is the table-like version:

header {
    height: 44px;
    background: orange;
}
article {
    box-sizing: border-box;
    border: 1px solid red;
}
footer {
    height: 22px;
    background: green;
}
html, body {
    height:100%;
    width:100%;
    margin:0;
}
body {
    display:table;
    border-collapse:collapse;
}
header, article, footer {
    display:table-row;
}
article {
    height:100%;
}
    <header>header</header>
    <article>article with small amount of content
        <br>
        <br>and a simple contact form
        <br>
        <br>this red border needs to meet the top of the footer
        <br>without creating a vertical scroll bar</article>
    <footer>footer</footer>

And here is the flex version:

header {
    height: 44px;
    background: orange;
}
article {
    box-sizing: border-box;
    border: 1px solid red;
}
footer {
    height: 22px;
    background: green;
}
html {
    height:100%;
    width:100%;
   
}
body { 
    min-height:100%;
    margin:0;
    display:flex;
    flex-direction:column;
}

article {
    flex:1;
}
    <header>header</header>
    <article>article with small amount of content
        <br>
        <br>and a simple contact form
        <br>
        <br>this red border needs to meet the top of the footer
        <br>without creating a vertical scroll bar</article>
    <footer>footer</footer>

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

Using an HTML element to pass a variable into a replace function

I am looking to highlight a 'SearchString' by replacing it with <span style="background-color: yellow">SearchString</span> within a targetString. The SearchString varies, so I am wondering how I can make this happen. This is what I ...

When the collapse button is clicked, I aim to increase the top value by 100. Subsequently, upon a second click, the top value should

https://i.stack.imgur.com/p9owU.jpghttps://i.stack.imgur.com/Kwtnh.jpg I attempted to utilize jQuery toggle, but unfortunately, it is not functioning as expected. <script> $(document).ready(function () { $(".sidebar ul li&quo ...

Utilizing CSS variables and HSLA, create a distinctive linear gradient styling

I am encountering an issue with a CSS variable: :root{ --red: hsl(0, 100%, 74%); } Despite defining the variable, it does not work in the following code snippet: .page-wrapper{ background-image: linear-gradient(hsla(var(--red),.6), hsla(var(--red),.6 ...

Is it possible to conceal a link once it has been visited?

I am trying to figure out how to remove a link from a page once it has been visited. However, I am facing privacy restrictions with the :visited pseudo-class. Is there a way to achieve this without using display: none? For example: .someclass a:link {dis ...

Harvesting the local image file

Currently, I have implemented a form that allows users to upload images and crop them. The process flow has been established as follows: 1. User uploads the image 2. Server processes the image and sends it back to the browser 3. User crops the image a ...

Preventing browsing beyond subdirectories in web file management without relying on a web server

I am currently in the process of developing a command line application that generates an index.html file containing links to other HTML files as well as links to subdirectories within the filesystem. An example of such a link is shown below: <a href=. ...

Has the Blueprint CSS framework become obsolete?

Is the Blueprint CSS framework still being actively maintained? The last version was released over a year ago and there have been no recent commits in the Github repository. ...

polygon with five or more sides

Can divs be created with shapes such as five or six corners? I am looking to create clickable zones on a map and any alternative methods would be greatly appreciated. ...

Embedded YouTube videos are not functioning properly in fullscreen mode

I've been utilizing the Embed tag on my website. It's functioning properly except for the FullScreen mode, which seems to be malfunctioning. <embed class="embed-responsive-item" src="https://www.youtube.com/embed/EngW7tLk6R8" allowfullscreen= ...

Troubleshooting WordPress <?php body_class(); ?> Problem

After successfully integrating my theme into WordPress, I decided to add WooCommerce to create a shop. However, I encountered an issue where the styles of WooCommerce were not appearing properly. Upon researching, I discovered that the root cause was the a ...

What is the proper way to place a newly added element using absolute positioning?

Currently, I am in the process of developing a tooltip feature. This function involves adding a div with tooltip text inside it to the element that is clicked. However, I am facing a challenge in positioning this element above the clicked element every tim ...

Discover how to display the loading time and memory usage of a web page on the footer using the jQuery and AngularJS library

Does anyone know how to display the loading time and memory usage of a web page in the footer using jQuery and AngularJS libraries? I've managed to show the loading time with this jQuery code: <script type="text/javascript"> before = (new Date( ...

The issue of the responsive navigation bar overlapping the header and navigation links not functioning properly

Hello everyone, I need some help with my website! I can't seem to find the answer on my own. I'm currently working on making my website responsive, but I've run into an issue with the mobile navigation on phones. The navigation links are ov ...

Expanding Highcharts Tooltip Size Automatically Based on Content Updates

I am dealing with a Highcharts graph that has tooltips showing a loading spinner upon hover. These tooltips fetch data from the server via AJAX, but when the content is updated, it overflows due to the tooltip not resizing. Below is the SCSS code snippet I ...

Tips for sending data to CSS in Angular

I have an Angular application where I need to calculate the width of an element and store it in a variable called finalposition. Then, I want to move this element to the left by (finalposition)px when hovering over it. How can I achieve this styling effect ...

Tips for displaying a loading indicator above a form

I've been struggling to figure out how to display a loading indicator on top of my form without messing up the styling... https://i.sstatic.net/FFCRW.png My goal is to show the loading indicator when any action, like deleting an item or changing qua ...

Header spanning the entire width with varying ends

Hello everyone, I'm currently working on a website and struggling to create a header similar to the image shown above. I want the header to span the full width of the page. Can anyone provide guidance on achieving this using HTML5/CSS3 without relyin ...

Adding more pixels to the height of an element does not actually make it larger

Recently, I've been working with material UI and I have a scrolling list of items that I want to resize to be larger. However, I've noticed that no matter how I adjust the height in pixels, the items never exceed 140px. Below is the code snippet ...

Capture sound and store it in a specified destination

Looking to capture and save audio files - any recommendations? After searching online, I came across some links for recording audio but they were all dead ends. I even downloaded and tested a few, but no success. I am open to using HTML5, PHP, JavaScript ...

Retrieve several values with a limit of 1 in SQL

Consider the following table structure: ID | ident | product 1 | cucu1 | 99867 | 2 | kkju7 | 88987 | 3 | sjdu4 | 66754 | 4 | kjhu6 | 76654 | 5 | cucu1 | 98876 | Running the query: SELECT ident,COUNT(*) FROM sales WHERE status=? AND team=? AND DATE(da ...