Drop-Menu - Tubular Formation of Columns

I am currently facing a challenge in creating a filter on a web page using Bootstrap's drop-down menu. The issue lies in placing the filters in columns side by side, as they are stacking up instead. The filter menu is generated dynamically by looping through an array of items to create each column. I attempted to use the grid layout with the row-cols-# class, but it did not yield the expected results.

Although I can manually set the width of the menu and adjust the position of the columns using the style property, this approach does not allow for proper sizing based on the number of columns present.

My sidebar navigation is constructed using d-flex, flex-row, and flex-column classes, leading me to question if these are contributing to the issues being faced?

To better illustrate the problem, here is a simplified version of the webpage: Filter Menu Help

Answer №1

A primary reason for the stacking behavior is due to the use of .col-auto in conjunction with the default flex-wrap: wrap; property of .row, causing columns to minimize and wrap accordingly.

Another factor contributing to this issue is the absolute positioning of the dropdown-menu relative to the .dropdown wrapper. Placing the wrapper on the right side limits the width expansion of the dropdown-menu.

To address these concerns:

  • Avoid using auto columns and instead specify a max-width for the dropdown-menu.
  • Eliminate the unnecessary
    <div class="dropdown"></div>
    wrapper.

Explore an example demonstrating how to configure your dropdown within Codeply based on your layout.

On smaller screens, column stacking is achieved by utilizing

<div class="row flex-column flex-sm-row">
. Each filter column integrates a list structure (
<ul><li>...</li></ul>
) for checkbox containment and styling flexibility.

<form class="dropdown-menu p-2 mt-1 overflow-auto">
  <div class="container-fluid">
    <div class="row flex-column flex-sm-row">
      ...
    </div>
    <div class="d-flex justify-content-end gap-3">
      <button type="reset" class="btn btn-sm btn-warning clear-filter">Clear Filter</button>
      <button type="submit" class="btn btn-sm btn-danger">Submit</button>
    </div>
  </div>
</form>

To control column wrapping, apply a max-width to the dropdown-menu. In the provided example, a width of 75vw is utilized for demonstration purposes, but any desired width can be specified. This approach simplifies maintenance compared to using row-cols-* and enhances visual aesthetics in column stretching scenarios.

For proper functionality of stretched-link, ensure that the parent element applies position: relative;. Additionally, maintaining whitespace: nowrap; aligns each <label> inline with its respective checkbox.

form {
 max-width: 75vw;
 max-height: 80vh;
}

.col li {
  position: relative;
  white-space: nowrap;
}

To prevent premature closure of the dropdown-menu on user interaction, include

data-bs-auto-close="outside"
on the toggler <button>.

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

What is the method for changing the color of text within a button when hovering using CSS?

In my OceanWP WordPress theme, I customized the top-bar menu by adding a button labeled "Post a Job" using CSS. Screenshot Link I have two top-bar menus - one for logged-in users and another for logged-out users. The "post a job" button has a 2px purple ...

The dropdown menu is missing in action, utilizing the power of Bootstrap and Google Apps Scripts to pull data from a spreadsheet

I've been struggling with this code for hours, everything seems correct but it just won't work Maybe someone can help me figure out what's wrong here The issue lies in the last function of the first file and in the second file, it's ...

how to choose the :after pseudo-element with jQuery

Below are the codes I have tried. When this popup appears, I want to be able to close the entire popbox using the close button. CSS code .bigdiv{ display:none; background-color:#efefef; box-shadow: 10px 10px 10px 100000px rgba(0, 0, 0, 0.4); ...

What is the best way to implement a loop using JQuery?

<script> $(function() { $('.slideshow').each(function(index, element) { $(element).crossSlide({ sleep: 2, fade: 1 }, [ { src: 'picture' + (index + 1) + '.jpg' } ]); }); ...

Replace jQuery CSS with standard CSS without using !important to override styles

Recently, I encountered a puzzling situation: I have an element with the following CSS properties ($(this) represents the cloned object): clone.css({ 'width': $(this).width() + 'px', 'height': $(this).height() + ' ...

The information overflow occurs outside the tooltip specifically in Chrome, while functioning perfectly in IE11

As a newcomer to the CSS world, I am experimenting with adding a block-level element (div) inside an anchor tag's :hover pseudo-class popup. The div element contains a table that needs to have dynamic sizing for both the table itself and its cells (wi ...

displaying and concealing elements with jquery

Is there a way to hide a div if the screen size exceeds 700px, and only show it when the screen size is less than 700px? Below is the jQuery code I'm attempting to use: jQuery(document).ready(function() { if ((screen.width>701)) { $(" ...

Is it possible to restrict the draggable area?

Looking at this JSFiddle example, there is a box that can be dragged around the body. But, is it feasible to restrict dragging only when the user clicks on the purple section identified by the id "head"? $(document).ready(function(){ $( "#box" ).dra ...

Creating a responsive layout with two nested div elements inside a parent div, all styled

I'm currently facing an issue with using padding in my CSS to make the two divs inside a parent div responsive at 50% each. However, when combined, they exceed 100%. I suspect this is due to the padding, but I'm unsure how to resolve it. .column ...

Changing the Div heights in Material UI with grid layout customization

I have a project that requires me to implement material-ui. Is there a way I can adjust the width and height of the div containing the "Sign In With" text (as shown in the first image) to bring the buttons closer to the text? Transformation from this: ht ...

Animating content through CSS and jQuery to reveal its unfolding effect

Just stumbled upon the amazing quote-expansion animation in the OSX Mail app and I am completely impressed. I am on a mission to bring that same magic to the web (or at least close to it), but unsure if anyone has done something similar yet. A couple of ...

difficulties arise when adjusting font size in html and css

When I first created an all HTML/CSS website, I used clickable images as a menu that scaled perfectly on all monitors and browsers. Now, for my new project, I wanted to use a background image for the menu with hyperlinked text on top. I thought setting the ...

Automatically, the "ng-hide" class gets added despite using the correct syntax for ng-show

I am trying to dynamically show/hide a tr tag within a table based on the value of a scope variable in the controller. Despite writing the code correctly, I am facing an issue where the "ng-hide" class is automatically added to the tr tag every time it is ...

Exploring Browser History using Cascading Style Sheets

Currently, I am in need of researching a topic for my University project. Unfortunately, the internet has not provided me with any information on this specific subject. The task at hand is as follows: "How and under what circumstances can one uncover ...

hide content on both desktop and mobile devices

I can't seem to figure out what's wrong here and my mind is blank. I have 2 tables - one for desktop users and one for mobile users. I attempted to hide one using the display none property in my code. .mobile{display: none;} This CSS was mean ...

Unresolved styles in React component linked to styles.css file

As I dive into creating a registration page in ReactJS, I encounter a frustrating issue with my styles not applying correctly from the styles.css file. Let's take a look at my RegisterPage.jsx component: export default function RegisterPage() { ret ...

Unable to get the Gtranslate function to function properly within the drop-down menu

Currently, I am using Gtranslate.io languages on my website with flags displayed without a drop-down menu. Everything is running smoothly but now I am looking to enhance the user experience by placing the flags inside a drop-down list. I want English to ...

How can we assign various class names depending on the value of an object?

I have a set of objects stored in my component. I need to dynamically apply different classes based on the value of the ErrorLevel property within each object. If an object has ErrorLevel equal to 1, I want to assign the following classes to various elemen ...

Is there a way to send me the result of the radio input (Yes/No) via email?

Is it feasible to send the results of a radio input (Yes/No) back to my email directly using HTML, CSS, and Javascript? ...

Could Chrome be miscalculating em unit values in media queries?

I have defined my media query breakpoints as shown below: @media screen and (max-width:48em){ /* phone */ } @media screen and (min-width:48.063em){ /* tablet */ } After using a PX to EM calculator to get the 48.063em value (as I was advised to us ...