Bootstrap and jQuery for creating columns of equal height

I'm currently utilizing Bootstrap in a web project and struggling to dynamically set the same height for column elements. I am aware of the .row-eq-height class, but using it compromises the responsiveness of Bootstrap elements. My goal is to ensure that the #selection column matches or exceeds the height of #map-container (especially considering its border, which should not cut off the content).

I've written a few lines of jQuery:

var map_height = $('#map-container').height();
var selection_height = $('#selection').height();
if (selection_height < map_height) {
  $('#selection').css('height',map_height);
}
<div class="row" id="selection-wrapper">
    <div class="col-lg-7 col-xs-12" id="map-container">
            <!-- Zone for map display -->
        <div id="map"></div>
    </div>
    <div class="col-lg-5 col-xs-12">
        <div class="text-container" id="selection">
            // Content
        </div>
    </div>
</div>

Although these lines function as intended, I am unsure of the best approach for executing them consistently to maintain equal heights at all times, even when the container width changes (impacting the height of #map-container).

Answer №1

function adjust_height() {
    var container_height = $('#container').height();
    var content_height = $('#content').height();
    if (content_height < container_height) {
        $('#content').css('min-height', container_height);
    }
}
$(document).ready(function(){
    adjust_height();
});
$(window).resize(function(){
    adjust_height();
});

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

Can we enclose a div within a bootstrap row, but not as a grid item

Can a div be wrapped inside a row without using column classes? While it is technically possible, some may argue that it is not the best practice. Let's explore this further. Take a look at the example below: <div class="row"> <div class=" ...

Adding elements to the <Head> section in Next.js

I am facing an issue where I need to change the page title dynamically based on the route of the web pages. I have been assigned the task of creating and importing a title component into the layout file, but despite my efforts, nothing seems to change. con ...

Guide to utilizing JavaScript and JQuery for retrieving a PDF from a specific URL and subsequently uploading the file to another website

I have a link to a PDF file: http://www.example.com/HelloWorld.pdf My objective is to download the file using JavaScript/JQuery/AJAX and temporarily store it in the browser, without saving it on the user's machine. Then, I want to POST it to . To ac ...

Having trouble retrieving the YouTube channel name using XPath node in Selenium and TestNG

My current task involves navigating to the YouTube website, entering the search term "qtp," and clicking on the Search button. Once on the results page, I need to extract the Channel Name. To achieve this, I used Firebug to identify the path for the first ...

When sending an Axios POST request, a "Network Error" message may be received even when the status code is 200 and there is a valid response

Currently, I am utilizing Vue JS version 2.5 along with Axios: "vue": "^2.5.17", "vue-axios": "^2.1.4", "axios": "^0.18.0", The main issue I am facing involves making a POST call like so: const data = querystring.stringify({ 'email& ...

Having trouble getting the CSS footer from cssstickyfooter.com to function properly

I tried implementing some basic CSS from to create a sticky footer that remains at the bottom of the page regardless of content length. However, I am encountering a problem with the footer not behaving as expected. There are actually two issues with the f ...

Mastering the Art of Scrolling

Can someone please tell me the name of this specific scrolling technique? I am interested in using something similar for my project. Check out this example site ...

Is it possible to customize the default styling options in Tailwind?

I am currently working on a blog using NextJS, and I have encountered an issue with Tailwind's list style type. It seems that the default styling for list style type is set to list-none, resulting in my <ul> <li> elements not being styled ...

What is the best way to implement an IF THEN ELSE statement using ngStyle in Angular?

How can I make rows in a table highlight based on the STATUS value? Currently, I have it set up to show yellow if the STATUS is 1 using the following code: [ngStyle]="{'background-color': cnresult.STATUS === 1 ? 'yellow' : '&a ...

Tips for activating the default 500 error page in Next.js

I'm having trouble getting Next.js to display its default 500 error page. While most sources discuss creating a custom error page, the Next.js documentation only briefly references their built-in 500 error page. I want the default page to show up when ...

Find all LI elements within UL containers that are not contained in a UL element with a specific class using jQuery

How can I select all elements from ul, excluding those with the class not-need? <ul> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <ul class='not ...

Ways to display two horizontal scrolling menu bars

I am in need of displaying two horizontal scroll menu bars on my website. After some research, I came across a custom horizontal scroll menu with left and right arrows. https://jsfiddle.net/c5grnve6/ While it works well with only one scroll menu on the p ...

Tips for incorporating a callBack function when the screen changes in react-native:

Is there a way to implement a callback function that executes whenever the screen changes, such as moving from the home screen to the about screen? Situation I would like to create a global stack that triggers a callback function whenever any navigation o ...

What is the process for utilizing window.caches to store pages within the window object?

While many demonstrations of saving an 'app shell' involve using a service worker, I have observed that it is also possible to access the caches object directly from the window. My inquiry is whether it is feasible to save pages for offline view ...

Looking for a way to automatically update a map within a Vue component

My component successfully: Receives a string from a sibling input component via the global Bus method in created() => works Manipulates the string into lat/lng coordinates via geoDecoding() => works Resolves promise result coordinates, sets data, a ...

What is the best way to position a static element next to a Vue draggable list?

I'm currently working on implementing a feature to display a list of draggable elements using vue-draggable. These elements are occasionally separated by a fixed element at specified position(s). My approach so far has involved creating a separate el ...

Problem with selecting items in Kendo UI Menu

Problem: The select event is not triggering when clicking on the image in the kendo menu item. My troubleshooting steps: Review the sample code provided below <!DOCTYPE html> <html> <head> <base href="http://demos.telerik.com/ken ...

Scrolling on an iPhone's Div

When I tried to access a website () using my iPhone and other gadgets, I encountered an issue with scrolling through the content. Clicking on the "Insight" link at the top-left corner led me to another page. On a computer, I had no trouble scrolling smoo ...

A guide to replicating HTML using AngularJS

I am attempting to replicate HTML content using AngularJS. While I was successful using jQuery, it caused conflicts with Angular. Therefore, I aim to achieve the same result using AngularJS. Here is the code I have written: function printContent(el){ ...

Unable to retrieve the value of the data attribute

Attempting to retrieve the data attribute from a dynamically created table using foreach loop. Currently, only able to get the value of data attribute serviceid from the first row. This is the PHP code: <?php foreach ($service_arr as $service) {?> ...