Dynamic double header and footer would be ideal for optimal flexibility

I'm not entirely certain if it's possible, but I am looking for a flexible solution using either flexbox or CSS table layout to create fixed headers and footers like so:

***header one - fixed - dynamic height***
***header two - fixed - dynamic height***
***content - scrolls as needed***
***fixed one - fixed - dynamic height***
***footer two - fixed - dynamic height***

I've spent countless hours searching and experimenting, and the closest I've gotten is with this JSFiddle. It works well overall, except that the header and footer content doesn't wrap when it exceeds the page width. I can consider fixed heights, but I prefer dynamic ones. Also, sometimes header two and footer one won't be present on the page.

If you have any insights or ideas, I would greatly appreciate them!

Answer №1

Yes, this solution seems to be effective.

It's crucial to include max-height to prevent the column from expanding uncontrollably, and in this case, it has been set to 100vh.

Check out the Codepen Demo

I am assuming that you didn't intend for the headers/footers to have a position:fixed, as that would remove them from the document flow and not impact the height of non-positioned elements.

Instead, I believe you meant that the main content should fit between them regardless of their size and overflow when necessary.

I've also added a hover effect on the content section to showcase the overflow functionality.

body {
  padding: 0;
  margin: 0;
}
.container {
  height: 100vh;
  max-height: 100vh;
  width: 80%;
  margin: auto;
  display: flex;
  flex-direction: column;
}
div {
  flex: 0 0 auto;
}
.one {
  background: lightblue;
}
.two {
  background: lightgreen;
}
main {
  flex: 1 1 auto;
  overflow-Y: auto;
  background: pink;
}
main:hover .expander {
  height: 1000px;
}
p {
  padding: 0 1em;
  margin: 0;
<div class="container">
  <div class="header one">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vitae, alias mollitia. Laborum et cupiditate</p>
  </div>
  <div class="header two">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex excepturi molestiae voluptates nesciunt, recusandae error,</p>
  </div>
  <main>
    <div class="expander"></div>
  </main>
  <div class="footer one">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur incidunt, esse quaerat illum ipsa. Reiciendis corrupti aliquid placeat</div>
  <div class="footer two">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum rerum tempore dolor tenetur expedita eligendi nemo numquam veniam laboriosam.</p>
  </div>
</div>

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

Expand Bootstrap accordion on hover

I have tried several examples that I discovered on Google and Stack Overflow, but none of them seem to work. So, I decided to attempt a different solution for opening the Bootstrap accordion on hover, however, it is not working as expected. Do you have any ...

Responsive design with Semantic UI

Can you please provide an example of how to design for different screen sizes using Semantic UI instead of Bootstrap? I'm looking for something similar to Bootstrap's sm and lg classes. For instance, would it look like this: <div class="col s ...

Using various alignment options for images on mobile devices

I've designed a theme with two columns, one for text and the other for images. I've structured it in HTML to display as: Text - Img Img - Text Text - Img Img - Text Text - Img Img - Text However, for mobile responsiveness, I want it to display ...

"Customize your Vuetify v-card with uniquely styled rounded corners on only

I am seeking to create a unique v-card design where only two corners are rounded. Despite my attempts, the card ended up rotated by 90° and didn't achieve the desired outcome. DESIGN ATTEMPT: <div class="text-center rotate-ninety ml-n6" ...

Placing an image within a table row that spans multiple rows to maintain center alignment in relation to other rows that are not span

Having trouble with centering the image in an email signature when viewed in GMail. The layout works fine in JSBin but appears uneven in GMail. Any suggestions on how to make sure it stays centered? Check out the code here https://i.sstatic.net/F2LXV.png ...

Mobile video created with Adobe Animate

Currently, I am designing an HTML5 banner in Adobe Animate that includes a video element. However, due to restrictions on iPhone and iPad devices, the video cannot autoplay. As a workaround, I would like to display a static image instead. Can anyone provid ...

Blur function not performing as anticipated

I am attempting to achieve a blur effect on a dialog pop-up. Currently, I am using the primeng p-dialog component for this purpose. <p-panelMenu [model]="items" [style]="{'width':'300px'}"></p-panelMenu> <p-dialog head ...

How can I extract information from an HTML table using AngleSharp?

Seeking a way to extract song data from a playlist on a music streaming website This table contains song information: <tr class="song-row " data-id="ef713e30-ea6c-377d-a1a6-bc55ef61169c" data-song-type="7" data-subscription-links="true" data-index="0" ...

When the bootstrap 5 dropdown is activated, flex wrap functionality triggers vertical scrolling

Every time I click on the dropdown, it causes a vertical scroll instead of popping out like a regular dropdown. I want to maintain the horizontal scroll while fixing this issue. Any suggestions on how to solve this problem? Demo: https://jsfiddle.net/d3j ...

Hiding Button in code behind

I have around 100 buttons in a list. Initially, I have set their visibility to false in the ASPX page. Now, I need to change the visibility to true from the code-behind when required. Since there are too many buttons, it's not feasible to individuall ...

Responsive Iframe设计

My website has an issue with making the iframe responsive. The map displays correctly on a computer, but is invisible on mobile phones. I am currently using Bootstrap for the layout. <div class="container d-none d-sm-block mb-5 pb-4"> <d ...

Image Filter: Only Display Selected Images, Not All

I have designed a Filter Image Gallery where all images are initially displayed when the page loads. There are four different tabs available - Show all, Nature, Cars, and People. However, I want to change this default behavior so that only Nature filter i ...

Hide overflow for images with unique shapes

Here are the two image layers: https://i.sstatic.net/lUUQC.jpg One shows a hand holding a phone, and the other is a black hole. This is how you can achieve it using HTML markup: <div class="wrapper"> <img class="wrapper__image" src="path/to/ ...

Adjusting the size of a Google map based on the size of the browser

Currently, I am working on implementing Google Maps API v3. The map is displaying perfectly on my page, but the issue arises when I resize the browser. Upon resizing, the map reverts to its original size as it was when the page initially loaded. This is t ...

Using CSS to align the position of a div with the last word position of an h4 element

Trying to figure out how to position a div at the end of an h4 text element has been challenging. When the h4 text is on a single line, it's easy to place the div correctly. However, things get complicated when the text spans multiple lines. In that c ...

Issues with 'floating' unordered lists

.menu li { float: left; color: #fff; font-weight: bold; } .menu li a { display: block; height: 20px; min-width: 110px; text-decoration: none; border-radius: 3px; padding: 4px; padding-left: 6px; padding-right: 6p ...

Styling unique text in an HTML text area

In the process of creating a web-based SQL editor, I am looking for a way to apply unique styling to certain SQL keywords (such as select, create, from) while a user is typing. Is there a way to achieve this using HTML alone? Alternatively, are there any ...

Positioning a box at the bottom rather than at the top

I am on the lookout for a solution to shift/arrange divs to the bottom instead of the top. For example, when attempting to delete some of the divs with the "box" class in this code snippet: Current code: #hol ...

Using Semantic-UI causes issues with the functionality of the height property set to 100%

View my CodePen here <head> <meta charset="utf-8"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.min.css"> </head> <body> <div class="ui secondary pointing menu" id=" ...

How to apply background-color to a div element with ng-repeat directive?

Hey there, I'm dealing with the following code: angular.module("myApp", []).controller("myController", function($scope) { $scope.boxList = [{ color: 'red' }, { color: '#F8F8F8' }, { color: 'rgb(50, 77, 32) ...