I am in search of a container that has full height, along with unique footer and content characteristics

I have set up a jsfiddle to demonstrate the scenario I am facing: There is a basic header, content, footer layout.

Within the content-container is a messenger that should expand to a maximum of 100% height. Beyond 100% height, it should become scrollable.

UPDATE: When I say 100% content-height, I mean that the content-container stretches between the header and footer. The header and footer are always visible, while the content-container and the messenger inside it stretch in between. However, the messenger starts scrolling when its content (the messages) exceeds the available space.

One exception is the footer: It has a unique behavior where it remains sticky until it reaches the content inside the content-container. Once the content surpasses 100% height, the footer stays at the bottom.

Unfortunately, I cannot provide a direct link to my fiddle due to restrictions on stackoverflow regarding "jusfiddle links must be accomplished by code."

/*BASIC STRUCTURE*/

* {
  padding: 0;
  margin: 0;
}

html {
  height: 100%
}

body {
  min-height: 100%;
  position: relative;
  font-family: arial;
  color: #FFF;
}

.wrapper {
  height: 100%; /*not working without set position absolute*/
  width: 100%;
}

.header {
  background: #2980b9;
  text-align: left;
  min-height: 70px; /*Height must be flexible*/
  width: 100%;
  border-bottom: 1px solid #f0f0f0;
}

.content-container {
  background: #336E7B;
  max-width: 1010px;
  text-align: left;
  margin: 0 auto;
  padding: 40px 10px 40px 10px;
}

.footer {
  background: #2980b9;
  padding: 10px 0 10px 0;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
}

p {
  padding: 10px;
}


/*END BASIC STRUCTURE*/


/*MESSENGER STRUCTURE*/

.messenger-container {
  display: flex;
}

.my-contacts {
  flex: 1 1 0;
  min-width: 275px;
  background: #FFF;
  color: #000;
  overflow-y: auto;
  height:100%; /*not working yet */
}

.message-window {
  background: #333;
  overflow-y: auto;
  flex-grow: 1;
  height:100%; /*not working yet*/
}

.single-message {
  background: #FFF;
  color: #000;
  margin: 10px;
  height: 200px;
}

.input-field-dummy{
  background: #F00;
}
https://jsfiddle.net/25vrsr2m/
/*END MESSENGER STRUCTURE*/
<div class="wrapper"> <!--maybe remove the wrapper?-->
  <div class="header">HEADER - flexible height</div>
  <div class="content-container">
  MESSAGE CONTAINER
    <div class="messenger-container">    
      <div class="my-contacts">
        <p>CONTACT 1</p>
        <p>CONTACT 2</p>
        <p>CONTACT 3</p>
        <p>CONTACT 4</p>
        <p>CONTACT 5</p>
        <p>CONTACT 6</p>
      </div>
      <div class="message-window">
        <div class="single-message">Single message</div>
        <div class="single-message">Remove me and resize window from large to small multiple times to see footer behavior</div>
        <div class="single-message">Remove me and resize window from large to small multiple times to see footer behavior</div>
        <p class="input-field-dummy">
  INPUT FIELD GOES HERE - always sticky at the bottom of message window.
  </p>
      </div>
    </div>
  </div>
  <div class="footer">FOOTER - always at the bottom, sticky until it reaches content of content-container, then it stays below</div>
</div>

<!--
Here goes my js and css before body ends
-->

Answer №1

Give this a shot: height: calc(100% -heightoffooter+header) and definitely add overflow scroll

If your header is constantly changing, you could try using JavaScript to handle it

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

Tips for achieving an eye-catching text and image layout on a single page of your Wordpress blog

I've been exploring ways to achieve a design concept for my blog layout. I envision having the text and thumbnail displayed side by side, each taking up 50% of the width until the image reaches its end. Once the image ends, I want the text to span the ...

When hovering over a hyperlink, an image appears but I want to adjust the image's position in relation to each link

I have a unique feature on my website where text hyperlinks reveal small thumbnail images when hovered over. This concept was inspired by an example I found on this page. I initially implemented the code from a post on Stack Overflow titled Display Image O ...

Similar to using `display:flex` and `justify-content: center`, you can achieve centered

I have a group of n children within a div. I want to arrange them in a single row and center them horizontally. If I were to use flexbox, I could achieve this by: display: flex; justify-content: center; Is there a way to accomplish the same layout using ...

"Utilizing multiple class names in Next.js to enhance website styling

Looking for a way to apply multiple classNames in Next.js, especially when dealing with variable classnames? I'm following the component level CSS approach. Take a look at my code and what I aim to achieve: import styles from "./ColorGroup.mod ...

CSS Problems in IE9 Causing Alignment Issues with Two Items in List Item

Take a look at this: JSFiddle The code looks fine in firefox, chrome, and opera, but in ie9, the numbers are shifting. Please see the image for reference. Everything is correct on the left, but on the right is ie9. I'm stuck and need help to solve ...

What steps should be followed to incorporate a horizontal scrollbar within the table's header?

I'm currently using Vue and Vuetify to create a unique layout that looks like this: https://i.stack.imgur.com/QBs3J.png The layout consists of a card with three rows: The first row displays the number of items and includes a search bar. The second ...

Try utilizing querySelectorAll() to target the second item in the list

As I delve into the world of HTML and JS, I came across the document.querySelectorAll() API. It allows me to target document.querySelectorAll('#example-container li:first-child'); to select the first child within a list with the ID 'exampl ...

Creating a unique custom icon by leveraging the material UI icons - a step-by-step guide

I am looking to create an arrow graphic similar to the one shown in the image below https://i.stack.imgur.com/k9TvH.png Originally, I was able to achieve this using SVG - <svg height='24' width='12' style={{ marginBottom: '-4p ...

"Uncovering the mystery of the missing element in Jquery's open

I have developed a click-to-show feature that opens and closes a div from left to right. You can view the demo here on jsfiddle.net In the demo, you will find a green-colored div. Upon clicking this div, another div opens from left to right. An interesti ...

What is the method, by using JavaScript or CSS, to include extra space at the end of text block without starting a new line?

Imagine having some text, and at the conclusion of each paragraph there is a (more)... link. The layout ends up looking like this: This is just an example paragraph. Click on the more link for additional information. (more...) Now comes the desire to i ...

Equal-height columns in a responsive grid system

I'm currently facing an issue with a layout that seems simple I am working on a design featuring 4 headline boxes. In the "desktop" view, all 4 boxes need to be of equal height. The same applies when viewed across 2 boxes in the "tablet" mode. Howeve ...

The Fade In effect in jQuery causes my fixed header to overlap with images on the page

This is the javascript snippet using jquery <script type="text/javascript> $(document).ready(function () { $('#showhidetarget').hide(); $('a#showhidetrigger').click(function () { $('#showhidetarget&apo ...

What is the best way to style the header of a table when scrolling in CSS?

Currently, I am facing an issue with applying the top CSS property to the thead element of a table while scrolling. I have attempted various methods but have been unsuccessful in achieving the desired outcome. Initially, I used the scroll event, however, ...

"Divs are now linked and drag as one cohesive unit instead of

As I was experimenting with making images draggable and resizable, I encountered a small issue. When I attempted to drag two or more images, they would merge into one large draggable object instead of remaining separate. My goal was to make each image drag ...

What's preventing the buttons from shifting positions?

Having some trouble with my Minesweeper Web Game setup. My buttons are stuck in place and won't budge. Can someone help me figure out what's wrong? Here's the code snippet I've been working on (FYI, using NetBeans 8.1 IDE) HTML: <! ...

Add a CSS and jQuery hover effect to display text over an image, requiring users to click twice on their mobile device

I have a bunch of panels for different categories that change the background image when hovered over, display some introductory text, and lead to a URL when clicked. However, on mobile devices, you need to tap the panel twice to activate the URL. What I&a ...

The toggle button appears to be lacking in CSS styling

I'm trying to create a dropdown button using Bootstrap and ng-bootstrap in my Angular project. Here's the HTML I've written: <div ngbDropdown class="d-inline-block"> <button class="btn btn-outline-primary" id="dropdownBasic1" n ...

Delete the placeholder image from a div once live content has been inserted into it

If I have a container div that displays an image when empty, but I want to remove the image when content is dynamically added to the container, what would be the most effective way to do this with jQuery? The usual method of checking if the container' ...

The CSS hamburger icon displayed in the browser features three bars of varying heights

Looking to create a hamburger icon menu using only CSS? Check out my implementation below which includes three span tags in the HTML document. .sidebar-toggle { display: inline-block; } .sidebar-toggle span { display: block; width: 1.5rem; heig ...

How to effectively handle submenus within a Bootstrap 4 mobile menu?

I am currently updating our website from Bootstrap 3.3.7 to Bootstrap 4. The header contains a navigation bar with dropdown items. https://i.sstatic.net/n2P6U.png <header> <nav class="navbar fixed-top navbar-expand-lg navbar-light bg-white bg- ...