Breaking columns in Firefox using CSS

I am currently exploring a cross-browser approach to create a columned layout for an unordered list. The content is generated by a CMS, so my options are limited to adding classes only. While I have been successful in creating columns, I also need to control where the columns break as they may not always be of equal length. This is how the markup appears:

ul {
  list-style: none;
}
.c3 {
  -moz-column-count: 3;
  -webkit-column-count: 3;
  column-count: 3;
}
.colBreak {
  -moz-column-break-before: always;
  -webkit-column-break-before: always;
  column-break-before: always;
  font-weight: bold;
}
<ul class='c3'>
  <li class='colBreak'>Item1</li>
  <li>Item2</li>
  <li class='colBreak'>Item3</li>
  <li>Item4</li>
  <li>Item5</li>
  <li>Item6</li>
  <li>Item7</li>
  <li>Item8</li>
  <li>Item9</li>
  <li>Item10</li>
  <li class='colBreak'>Item11</li>
  <li>Item12</li>
  <li>Item13</li>
  <li>Item14</li>
</ul>

The CSS code functions well in Chrome and IE/Edge, but encounters issues in Firefox:

The objective is to achieve a 3-column layout, with Item1, Item3, and Item11 appearing at the top of each respective column.

In Chrome, the layout displays correctly:

In Firefox, the formatting on Item1, Item3, and Item11 does not render as expected.

JS Fiddle

Answer №1

I managed to achieve the desired outcome by adjusting the output, incorporating additional classes, and utilizing jQuery. Instead of explicitly marking where the column breaks should occur, I assigned specific column classes to each navigation item.

<ul class='c3'>
  <li class='col1'>Item1</li>
  <li class='col1'>Item2</li>
  <li class='col2'>Item3</li>
  <li class='col2'>Item4</li>
  <li class='col2'>Item5</li>
  <li class='col2'>Item6</li>
  <li class='col2'>Item7</li>
  <li class='col2'>Item8</li>
  <li class='col2'>Item9</li>
  <li class='col2'>Item10</li>
  <li class='col3'>Item11</li>
  <li class='col3'>Item12</li>
  <li class='col3'>Item13</li>
  <li class='col3'>Item14</li>

Subsequently, through the utilization of the jQuery wrapAll function, I applied bootstrap classes to divide the content into columns:

$(".c3 .col1").wrapAll("<div class='col-sm-4' />");
$(".c3 .col2").wrapAll("<div class='col-sm-4' />");
$(".c3 .col3").wrapAll("<div class='col-sm-4' />");

This process consolidated all .col1 items within a <div> element and introduced breaks without relying on spacers.

View operational example in Firefox via JS Fiddle

If there exists an alternate approach that achieves this task more effectively, I am eager to explore it. Nevertheless, the current method satisfactorily resolves the specified issue.

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

mixture of fluid and static width list items

Here is my custom HTML code snippets: </div><!-- /end .topbar --> <ul class="nav"> <li class="first"><a href="#">Time added</a></li&g ...

Manipulate the starting frame of the SWF file

Typically in regular swf files, they play from frame 1 to the end and then loop... Is it feasible to utilize javascripts or any scripting language to initiate playback from a specific frame, such as frame 10? Thank you. ...

Blurred background images following the upgrade to Internet Explorer 11

This morning, I received an automatic update to IE 11 and noticed that some of my background images appeared blurry. After confirming that the images were not the issue, I opened Chrome and saw that they were crisp again. This left me completely puzzled. ...

What is the proper way for a browser to handle a srcset attribute containing the same path twice?

When the same path or similar sized images with different pixel density descriptors are used, how does the specification address it? An interesting case study is observed when viewing an image in desktop browsers like Windows Firefox 82.0b2 and Chrome 85. ...

CSS Causing Numbers to Display in the Incorrect Direction

I'm attempting to showcase numbers in a single line using CSS. It's almost perfect, except the numbers are appearing in reverse order (e.g. 4 - 3 - 2 - 1 instead of 1 - 2 - 3 - 4). I've tried utilizing "direction: ltr" without success. My C ...

Issue with a Jquery toggleClass function not working properly on hover

Hello everyone! I am a newbie in the community and relatively new to the world of web programming. I am encountering an issue that is really frustrating me. I attempted to use this code to add a class when hovering over the ul list element so that I can d ...

Hide an Angular button when a page is loaded, depending on the information found in a table

How can I hide the Submit button in a table row if a certain condition is met based on information from the database? I attempted to create a function that returns true or false, but it ends up crashing my program because it runs continuously. I also trie ...

Is it possible to utilize the 'in' operator to locate the term 'length' in... Is there a need to modify the string?

I have been looking through the existing questions but haven't found a solution that completely explains how to resolve my issue. As someone new to JSON, I'm still trying to grasp all of its concepts. My goal is to create a dynamic table where us ...

Is it possible to add and delete DIVs simply by clicking on a link?

By utilizing a select dropdown list and appending the HTML code stored in the variable "code" (resembling <div>...</div>) right before the end of the div with ID mydiv using $(code).appendTo('#mydiv');. Within these dynamically added ...

What is the best way to center-align elements?

I have a couple of inquiries. First off, I'm facing an issue with centering everything within a form while aligning the text to the left side of the fields. I've attempted using justify-center and align-items within the "container" class and th ...

After modifying the select option, the input field remains disabled

I successfully developed a self-contained code snippet that toggles the enable/disable state of input fields. It works flawlessly on my HTML page. Check it out below: Identification Type: <select name="Identification-Type" id="Identification-Type"& ...

"The presence of the <textarea> element is causing disruptions to the

I'm currently attempting to insert infusionsoft contact form code into a CodeBlock within the Avada theme. However, I've encountered an issue with a textarea field in the form that contains the following code: <div class="infusion-field"> ...

5-item carousel in CSS gridView

I'm currently working on a thumbnail slider project. My goal is to display 5 thumbnails at a time, and allow users to move to the next or previous set of thumbnails by clicking on the corresponding buttons. I attempted to modify an existing slider tha ...

What is the best way to customize the styles of an autofilled input in Chakra UI?

Currently, I am customizing the styling of my input fields using Chakra UI's extendTheme function. However, I have encountered a challenge with styling inputs that have been auto-filled. The :autofill pseudo selector does not seem to work as expected ...

Generating a webpage with a distinct serial number

Within my PHP page, I have gathered various values from the previous page and included a print button that allows users to print all of these fields along with a unique number. However, the issue arises when multiple users are logged in simultaneously as t ...

The properties of JavaFX in the CSS file are not recognized by Eclipse, showing an error message as "unknown property"

After installing Eclipse and downloading the OpenJFX SDK, I encountered an issue where Eclipse marked all -fx- properties in the .css file as warnings with the message "unknown property". Surprisingly, my JavaFX projects still compiled and ran smoothly, ...

Using JavaScript to grab an entire div containing an SVG element

I am looking to capture an entire div as an image and save it locally as proof. Despite reading numerous articles on converting SVG to image or div to image, I have encountered challenges in achieving the desired result. Several attempts with JavaScript l ...

The ideal choice for a default background image in terms of style and dimensions

I'm using this code to set a background image for my website. body{ background: url('path_to_image'); background-size: 100%; } I find that the background-size property works well for handling different screen sizes. I'm creating ...

Transfer the values selected from checkboxes into an HTML input field

I am attempting to capture the values of checkboxes and then insert them into an input field once they have been checked. Using JavaScript, I have managed to show these values in a <span> tag successfully. However, when trying to do the same within a ...

automating the styling of elements

Hey everyone, I have a specific element that I want to conditionally apply multiple styles to. Initially, I approached it like this: <Text style={[ discountCodeState === '' || !isActiveHandler(value) ? [ ...