Prevent lengthy headers from disrupting the flow of the list items

I've encountered an issue while working on a website that features a list of items. When the title, such as "roller blinds," spans across two lines, it disrupts the layout below. How can I prevent this from happening without compromising on having longer titles?

CSS:

#solutions-categories .inner-box{
    padding:20px;}

#solutions-categories ul{
    padding:0;
    margin:0px -10px;
    list-style:none;}

#solutions-categories ul li.solution-category{
    width:25%;
    float:left;
    padding:0px 10px 40px 10px;}

.solutions-category-image{
    margin-bottom:20px;}

.solutions-category-image img{
    height:auto;
    width:100%;}

.solutions-category-title h3{
    margin: 25px 0px 15px 0px;}

.solutions-category-title .divider{
    margin-bottom: 25px !important;}

Attempts to solve the problem by switching to floated divs instead of li elements or using JavaScript to set equal heights have been unsuccessful.

Answer №1

When designing a layout, it is important to either allow vertical space for the longest possible title or utilize JavaScript to calculate the tallest title and adjust others accordingly.

jQuery(function($) {
    var maxTitleHeight = 0;

    $('.solutions-category-title h3').each(function() {
        var titleHeight = $(this).height();

        if (titleHeight > maxTitleHeight) {
            maxTitleHeight = titleHeight;
        }

        $(this).height(maxTitleHeight);
    });
});

It is recommended to assign a name to this function and call it on window resize to ensure the titles stay consistent.

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

Could the conflicting interaction between CSS transformation and animation be resolved by adjusting the order of the HTML elements

Hey there! I'm facing an interesting challenge with my menu design. The menu has rounded ends and diagonal spaces created using CSS transform skewx. Additionally, I have an animated element on the page. The issue arises when the animated element is p ...

Develop a responsive design for a row of icons that automatically flows to a second line when the screen size is

Currently, I am utilizing Bootstrap 4 and attempting to design a row of 12 icons that are responsive. <div class="app-container"> <div class="row"> <div class="col-md-1"> <a class="" href="https://www.xxx.org.au"> < ...

Having trouble inserting a new row into the AngularJS table?

Having trouble adding a new row to the table in angularjs when clicking the add button. Here is the link to the Plunkr example -https://plnkr.co/edit/s7XAaG4JbvbTTxiZ0V2z?p=preview The HTML code snippet is as follows: <html> <head> <script ...

Animating the appearance and behavior of radio buttons using CSS transitions and JavaScript

My jQuery code allows me to fetch attributes from the .item element, but I'm having trouble with my CSS transitions not working as intended. To see the desired transition effect, try replacing .item with .item-tile. How can I make my CSS transitions ...

Changing HTML5 input type date into a string representation

Here is my PHP code snippet: <?php include 'config.php'; if(isset($_POST['submitbtn'])){ $date = $_POST['datefield']; $newDate = date("Y-m-d", strtotime($date)); $result = mysql_query("Call seat(".$newDate.")"); if($resu ...

What is the procedure for selecting an element based on its child containing specifically filtered text?

Imagine a webpage with the following elements: <div data-search="type1"> any HTML <!-- .click is a child of any level --> <span class="click" data-source="page1.html">blue</span> <!-- let's call it "click1 ...

How do I hide a dropdown menu when the selector's value changes in iOS6?

I'm currently developing a hybrid application using Worklight. When I tap on a select control, a native dropdown appears. However, when I choose an option and the onchange event is triggered, the dropdown doesn't disappear unless I tap on the do ...

Troubleshooting issues with cloning a row using jquery

I'm having trouble figuring out why my code isn't working. I want to duplicate a div and add it to the beginning of its parent div. Here's the code I have so far: //Adding a new row function addRow(btn) { var CopiedRow = $(this).closest( ...

How to use AngularJS directives to replace text with stars (*) in HTML

I am in need of a textarea control that has the ability to be masked, meaning that the text displayed should appear as stars instead of the actual characters. Since I might have multiple textareas in my form, saving the actual text in one variable and usi ...

Maintain text area spacing using JavaScript

Could anyone assist me in finding a script that can change line breaks from a user's textarea input into HTML upon form submission to ensure that the formatting is maintained in our notification emails? Currently, I am encountering an issue where fie ...

Separate your buttons with style using the Bootstrap button groups with

Is there a way to add border line separators between buttons in Bootstrap button groups? <div class="btn-group" role="group" aria-label="Button group with nested dropdown"> <button type="button" class=&quo ...

Navigating to a different page in the app following a document update: a step-by-step guide

I am facing an issue with a page where I am trying to print a specific DIV using the script below... function printReceiptDiv() { var divElements; if (vm.isDLR) { divElements = document.getElementById("DLRreportCont ...

Checking boxes on Android for compatibility with Firefox, Chrome, and Internet Explorer 8

Could anyone assist me with finding Android checkboxes styled with CSS and/or jQuery for my project? I haven't been able to find any resources or plugins that could help. Any links you can provide would be greatly appreciated as I've come up empt ...

Select the M3 element in a ul using CSS targeting

I am working with a ul containing some li elements, here is an example: <ul class="M199 WIDTHBOX1 5ColumnBox"> <li class="M2"> <a class="M2" href="about-1561.aspx" target="">About</a> <div class="WIDTHBOX2" s ...

Is there a way to manipulate CSS to update automatically when new content is loaded via ajax?

I need help with customizing the CSS for 4 image links on my website. Each link is represented by a small image in its normal state and a larger image when hovered over. The content for each link is loaded using ajax. My question is how can I modify the C ...

Retrieve a specific child element by clicking on a custom control on the map

I have a container element with three child spans. Using JQuery, I can determine which child was clicked when the container is clicked by utilizing the following function: $('.unitContainer').on('click','span',function(){ ...

When you hover over the page, the content shifts to reveal a hidden div

Trying to figure out how to show additional content when a photo is hovered over without shifting the rest of the page's content placement? Looking for alternative solutions rather than using margin-top: -22%. Here's a link to the website in que ...

Using a jQuery script, you can enable a back button functionality that allows users

I created a survey to assist individuals in determining where to go based on the type of ticket they have. However, I am currently facing difficulties with implementing a "Back" button that will display the previous screen or "ul" that the user saw. Initia ...

How can I delete a CSS class from an element?

Is there a way to remove the "ui-widget-content" class from the code below? It appears in multiple places throughout my code. Here is an example snippet: <pre> <form id="clientForm"> <div id="clientData"> <div id="gbox_grid_1" class=" ...

Implement a fadeout effect by using a timeout function that adds a class to the div element in

I implemented a loader on my webpage that animates for 3 seconds before a function kicks in to modify the styles and make it invisible. I am looking to add a fadeout effect when the 'waa' style is applied to the 'load' div. setTimeou ...