Tips for organizing a div into a dock panel

I am seeking guidance on how to align and resize the following divs based on my specific requirements outlined below.

Area A Area A should remain at the top with a set height that will not change.

Area B The height of Area B should vary between 0 and a minimum height. When the height of B is 0, Area C should expand to fill the space originally occupied by B.

The height of Area B can also increase from the minimum height to a value greater than the minimum height (X (X > min-height)). In this scenario, Area C should shrink to accommodate the increased height of Area B.

Area C Area C serves as the content area of the page and its height should adjust according to the height of Area B.

Area D Area D should stay fixed at the bottom of the page with an unchanging height.

I would like to know if it is feasible to achieve the above layout using CSS alone or if JQuery is necessary. If CSS can accomplish this, I am interested in understanding how? (Note: I have experience with achieving this using JQuery)

*I am coding in CSS3/HTML5

UPDATE I have included a link to this JSFiddle for reference.

I am uncertain if this question complies with the conditions of Stack Overflow. If not, please feel free to remove it.

Answer №1

If you're considering browser support, the use of flexbox is a common solution. It's worth noting that while flexbox works well on most modern browsers, it does not have compatibility with IE 8 and 9. You can check out details here. I've actually written a blog post discussing this specific layout concern - feel free to read it here. One important thing to be aware of is the difference between the old draft syntax and the current standardized syntax supported by most browsers.

The setup for using flexbox goes like this:

  1. Create a container for A, B, C, and D. Apply

    display: flex; flex-direction: column; height: 100%;
    to this container.

  2. A, B, and D maintain their own heights without additional requirements.

  3. C should expand or shrink to fill the leftover space. Use

    flex-grow: 1; flex-shrink: 1; flex-basis: 0;
    or its short form flex: 1 1 0; on this element.

If flexbox isn't an option, consider using JavaScript as a fallback method. This involves adding a resize event listener to the window, measuring the heights of A, B, and D, and assigning the remaining height to C dynamically. Check out how this is done on https://jsfiddle.net/ with the id="content" div for reference.

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

Need to delete the product page link on WooCommerce?

I am currently working on fixing the one-page checkout process and I need to remove a single product link from a product picture. The goal is to have only the checkout link displayed on this page, specifically within a quickview view. After trying out var ...

Issues with CSS styling are affecting the display of a form

Hey there! I was working on creating an order form for my website, and everything was going smoothly until I hit a snag while styling the webpage. The problem is that the legends of the form are extending all the way to the right side of the page, and the ...

Unable to close modal after receiving ajax response

Utilizing mdbootstrap for my current project has been a great experience. One area that I am struggling with is implementing an AJAX call upon checking a checkbox, where I expect a response from PHP indicating success (1) or failure (0). However, despite d ...

Transferring Data Between Tables in ASP.NET Core

I'm in the process of creating a new online store with ASP.NET Core. I have a requirement to transfer data from the Products table to the Items table upon clicking a button, so that the item information can be displayed on the shopping cart page. Any ...

The functionality of XPATH does not seem to be properly executed with JQuery

<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("[href!='http://w ...

What is the best way to eliminate the bottom border of an input field?

Seeking advice on how to eliminate the border-bottom of an input field when typing starts. .car-list-input { font-family: 'Source Sans Pro', sans-serif; border-radius: 3px; font-size: 14px; font-weight: 400 !important; height: 35px; ...

Ways to determine if an element has exceeded its container's boundaries

After creating the codesandbox, I have developed a webapp that heavily relies on user input. To keep it simple for demonstration purposes, I am displaying various authors on an A4 formatted page using `page` and `font-size` with the `vw` unit for responsiv ...

Assign the two values to variables in the CSS script

My challenge lies in passing two values to the CSS within the <style> tags. The values are: (background-color: --placeholder; color: --placeholdtext;). I am able to pass either one of the values successfully, but not both at the same time. When I cop ...

Is there a flaw in how Firefox handles text-overflow and inline-block?

It seems that according to the text-overflow specification, the ellipsis effect only applies to inline elements: This property defines how content within an inline element is displayed when it overflows its container's boundaries in the inline dire ...

A step-by-step guide to setting up a Slick Slider JS slideshow with center mode

I am working on implementing a carousel using the amazing Slick Slider, which I have successfully used for images in the past without any issues. My goal is to create a 'center mode' slideshow similar to the example provided but with multiple div ...

Is there a way to determine the total number of colors present in an image?

<?php $img=imagecreatefrompng('dense.png'); list($width, $height)=getimagesize('dense.png'); $t=0; for( $i=0 ; $i<$height ; $i++ ) { for( $j=0 ; $j<$width ; $j++ ) { $pix = imagecolorat($img, $i, $j); ...

Incorporating a hyperlink into an Iframe triggered by Fancybox2-AJAX, specific to the Iframe's unique identifier

One thing I have noticed is that everything seems to be working fine up until the point where I try to load it through fancybox via AJAX. An example of it working statically: <iframe id="videourl1" width="640" height="340" src="" frameBorder="0">& ...

Automatically close the modal upon receiving a valid input

When it comes to my modal, I've figured out how to show validation errors. My challenge now is preventing the modal from closing when there's an error in my ajax function. On the flip side, I'm also unsure of how to automatically close the m ...

How to fetch an image from a web API using JavaScript

I have recently entered the world of web development and I am facing an issue where I am trying to retrieve a Bitmap Value from a web api in order to display it on an HTML page using JavaScript. However, despite my efforts, the image is not getting display ...

The Bootstrap modal causes the scrollbar to vanish upon closure

Despite trying numerous solutions and hacks on this issue from StackOverflow, none of them seem to work for me. Currently, I am utilizing a modal for the login process in Meteor (e.g. using Facebook login service) which triggers a callback upon successful ...

The allure of Beautiful Soup lies in its ability to effortlessly gather every <br/> tag nestled within the <strong> element

I'm facing a peculiar issue that's getting on my nerves. Trying to convert HTML into markdown, but the formatting of my HTML is quite unusual. It includes things like: <strong>Ihre Aufgaben:<br/></strong> and <strong> ...

Using JQuery to create animations with fadeIn and fadeOut effects is a great way to

As a complete newbie taking my first steps in front-end development, I spent most of my day trying to work out an animation function but couldn't quite get it right. Below are the snippets of HTML, CSS, and JavaScript codes: <!DOCTYPE html> < ...

Issue with Radio Button Value Submission in Angular 6 and Laravel 5.5

I developed a CRUD application utilizing Angular and Laravel 5.5. Within this application, I included three radio buttons, but encountered an error when trying to retrieve their values... A type error occurred indicating it was unable to read the data t ...

Error message "Invalid postback or callback argument" occurs when a button within a GridView, placed in an UpdatePanel, is clicked

I'm attempting to implement a jQuery confirm dialog that calls a web method. The dialog should be triggered when the delete button within a GridView in an UpdatePanel is clicked. However, upon clicking the button, I encounter an error stating "Invali ...

Revise the JSON data by incorporating user-provided input and transforming it into XML

I need to take CSV data, display it to the user with input fields, and then update Json before converting everything to XML. Can I update Json using user inputs, or is there a different approach? $(document).ready(function() { $.getJSON( &apos ...