Design a web page with a responsive grid layout that features three resizable areas

Seeking assistance in creating a webpage with 3 resizable divs inside a container. The left and right divs should be resizable by the user while the center div adjusts accordingly. Similar to coding sections in platforms like plunker or jsfiddle, the layout must remain horizontal without shifting to the next line. This challenge has been perplexing me for almost a week now, any guidance or suggestions are welcome.

Note: Utilizing AngularJs for this project, so solutions incorporating Angular approaches are preferred, although other methods are also acceptable.

Update:

To clarify, the divs should be resizable by the user, rather than just resizing based on browser window changes. For example, clicking on the border of an area should expand it and adjust the size of the center area accordingly. Currently, my implementation is not responsive and exhibits bugs when resizing after both left and right areas are minimized. A smoother behavior similar to JSFiddle's interactive resizing feature is desired, where adjusting one area impacts the others smoothly.

For reference, here is a link to my plunker. Any insights would be greatly appreciated.
Thank you in advance.

Answer №1

My apologies for misunderstanding the question initially. The request was actually for a resizable grid, not equal height columns.

Below is a simple example demonstrating how vertical resizing can be implemented on a container using jQuery:

Here are the sources in this jsFiddle

Basic Javascript code snippet:

var diff = {x: resizeStart.x - e.clientX,y: resizeStart.y - e.clientY}; //Get the difference
resizeStart = {x: e.clientX, y: e.clientY}; // set new starting point

$('.left').width($('.left').width() - diff.x); // Set width of left container
$('.center').css('margin-left', parseInt($('.center').css('margin-left')) - diff.x); //Set margin of center container

This script saves the initial mouse drag position and calculates the difference with the current mouse pointer location. It then adjusts the width of the left container and the margin of the center container accordingly.

I hope this clarifies the solution for you.

Answer №2

When floating containers to the right or left, they often fall out of the layout causing issues. Unfortunately, there is no default solution to this problem.

One workaround is to calculate the height of both the left and right containers after the page loads, and then set the minimum height of the center container to match. An example using jQuery can be found in this jsFiddle.

Here is an HTML example:

<div class="left">
    <div class="left-content">
        Left Column <br/><br/><br/>more rows please...<br/><br/><br/>more rows please...
    </div>
</div>
<div class="right">
    <div class="right-content">
        Right Column <br/><br/><br/>more rows please...
    </div>
</div>
<div class="center">
    <div class="content">
        Center Column
    </div>
</div>

And the corresponding CSS:

.left {
    float: left;
    width: 200px;
    background: red;
}
.right {
    float: right;
    width: 200px;
    background: green;
}
.center {
    margin: 0 200px;
    background: yellow;
}

For the JavaScript part:

$(document).ready(function() {
    var max_height = 0;
    $('.left, .right, .center').each(function() {
        if($(this).outerHeight() > max_height) max_height = $(this).outerHeight();
    }).css('min-height', max_height);   
});

There are alternative CSS tricks available, although some may be complex or not entirely valid. Search for "equal height boxes" for more options.

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 handling external CSS dependencies in a Create React App project

Working on a web application using CRA 3.4.1 along with a component library called PrimeReact 4.1.2. My custom CSS is processed through the PostCSS setup in CRA, which adds prefixed versions for properties like display: flex to ensure IE10 support in the ...

Incorporating CSS into React.js applications

I am currently working on a project using MERN.io. In my project, I am utilizing the React.js component Dropdown. However, the Dropdown component does not come with its own style and CSS, resulting in no styling at all. ... import Dropdown from 'rea ...

Is there a way to detect when a CSS background image has finished loading? Does an event trigger upon completion?

I am facing an issue with my sidebar widget where there is an image background in place. On top of this, I have a search input form but I don't want the input to display until the image has fully loaded. Is there a way to add a load event handler to ...

Leveraging $this in conjunction with a jQuery plugin

I'm experimenting with a code snippet to reverse the even text in an unordered list: $(document).ready(function () { $.fn.reverseText = function () { var x = this.text(); var y = ""; for (var i = x.length - 1; i >= 0; ...

Combining blend-mode and filter in CSS: A comprehensive guide

Looking to achieve a specific image style by transforming a full color photo in the following ways: Convert it to greyscale Adjust the black levels (via decreased opacity or brightness) Apply a "multiply" blend mode with a blue color overlay So far, I&a ...

Symbol adjacent to button with multiple lines

My objective is to design a button with multi-line text and an icon positioned centrally next to it for both lines. Refer to the screenshot below for clarification: https://i.sstatic.net/ODPI2.png Despite my efforts, I am encountering difficulty in cente ...

Loading CSS files in Next.js can sometimes require additional time for the styles to

Currently, I am working on a Next.js and Spring Boot project. However, I am facing issues with the loading of CSS files as they are taking a considerable amount of time to load. When I open a page, initially it appears without any styling, but after a few ...

Prevent inspection of elements in Angular 2

Is there a way to prevent users from using inspect element on my website? I have disabled text selection, but users are still able to copy content through inspect element. ...

Radio buttons failing to transfer any data

I am experiencing an issue with setting values for radio buttons and using the $_POST variable to read the value, but the value being set is empty. <form style="text-align:left;margin-left:80px;" class="form-inline signup" role="form" method="post" act ...

Utilize jQuery to wrap text within <b> tags and separate them with <br> tags

Upon receiving output in html string format from services, I am presented with the following: "<html>↵<h1>↵Example : ↵<br>Explanation↵</h1>↵<hr>↵<b>key1 : ABCD <br>key2 : 2016-10-18-18-38-29<br> ...

Tips for manipulating fixed elements while navigating through the window's content

I am currently working with Materialize CSS (link) and I'm trying to figure out how to move select content while scrolling the page or when the window is scrolling. However, the example code I've implemented doesn't seem to be working. Is th ...

Establish a background image that can be scrolled

Currently, I am working on a project and have created a fiddle that can be accessed here: https://jsfiddle.net/0g3u8452/1/ The image I am using is 1920x4000, and I want it to span the full width of the screen similar to setting background-size ...

Creating a navigation bar in React using react-scroll

Is anyone able to assist me with resolving the issue I am facing similar to what was discussed in React bootstrap navbar collapse not working? The problem is that although everything seems to be functioning properly, the navbar does not collapse when cli ...

Library of Angular components - utilizing images in templates

I am currently using an npm package that contains several angular components. These components reference images in their templates. I have noticed that if I manually copy the images to my application's images directory, the references are resolved. Ho ...

Can you tell me the equivalent of this Curl command in Angular JS?

Execute the Curl command with the datavalueset XML file at "", using the Content-Type application/xml and authentication credentials admin:district, while also running in verbose mode. ...

Issue with DIV height in Internet Explorer occurs only when application is accessed using server name

Encountering a unique issue specific to IE (confirmed in v8 and v9). When utilizing jquery to determine the height of a div: $('#sys_MainPage').height() In Chrome, Firefox, and when accessing using the IP address, this code returns around 26 ...

When using ngOptions, remember that ngModel can be set to an entire object, not just its value

I am struggling to set my ng-model to hold the value of the select instead of the entire object. HTML <select name="status" data-ng-model="search.status" data-ng-options="s.label for s in statuses"> </select> $scope.statuses ...

Begin with a Bootstrap non-fluid container and follow with a fluid container

I am currently facing a challenge where I want the lower section of my webpage to be full width within a container-fluid div, while keeping the top part in a traditional container with a set width. Despite my efforts, the following HTML snippet is not ach ...

How can you selectively send only the values of chosen checkboxes when dealing with hidden inputs that share the same name?

Is there a way to send only the values of selected checkboxes that are linked to hidden fields with the same name in PHP? php <input type"checkbox" name="<?echo $filename;?>_<?echo $variable;?>" id="filename_<?echo $variable;?>" valu ...

WordPress: Struggling to Show Sub-Menu on Hover Feature Not Functioning

I'm having trouble getting the .sub-menu to appear when hovering over the 'about' page in my WordPress navigation. It doesn't seem to be working as expected. I'm not sure whether the issue lies with my jQuery or my CSS. What modif ...