Troubleshooting Problem with Flexbox and Expandable/Accordion Side Menu

I currently have a wrapper class that contains an expandable side menu and main content section positioned side by side. The side menu acts as a filter for the content displayed in the main area, but I am encountering an issue where the rows separate when there is less content/items than available space. I would like the rows to stay aligned with equal spacing between them regardless of the amount of content.

Is there a way to prevent the sidebar from affecting the layout of the main area, whether it is fully expanded or collapsed?

.main-content {
  display: flex;
}

.outer-wrapper {
  display: flex;
  flex-direction: column;
  margin-top: 2rem;
  justify-content: start;
  width: 100%;
  height: 100%;
}

.main_gallery {
  width: 80%;
  justify-content: flex-start;
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 0;
}

a {
  text-decoration: none;
}


/* side bar styling */

.side-bar {
  margin-top: .6rem;
  flex: 0 0 12em;
  min-height: 0em;
}

ol {
  list-style-type: none;
  padding-left: 0;
  font-size: .8em;
}

.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 12rem;
  text-align: left;
  border: none;
  outline: none;
  transition: 0.4s;
}

.active,
.accordion:hover {
  background-color: #ccc;
}

.panel {
  padding: 0 18px;
  background-color: rgb(255, 255, 255);
  display: none;
  overflow: hidden;
  text-align: left;
}
<div class="outer-wrapper">
  <div class="main-content">
    <!-- side bar -->
    <div class="side-bar">
      <button class="accordion">Misc.</button>
      <div class="panel">
        <ol>
          <li>
            <input type="checkbox" category="misc" id="demo reel,reel"> Demo Reel
          </li>
          <li>
            <input type="checkbox" category="misc" id="promo"> Promo
          </li>
          <li>
            <input type="checkbox" category="misc" id="setup,set up"> Setup
          </li>
          <li>
            <input type="checkbox" category="misc" id="settings"> Settings
          </li>
          <li>
            <input type="checkbox" category="misc" id="training,webinar"> Training
          </li>
        </ol>
      </div>
    </div>
    <!-- end of side-bar-->
    <main class="main_gallery">
      <!-- video thumbnails template goes here -->
    </main>
  </div>
  <!-- end of main-content-->
</div>
<!-- end of outer-wrapper-->

View flexbox issue

Answer №1

After some troubleshooting, I successfully resolved the spacing issue in my .main_gallery class by incorporating align-content: flex-start; into my CSS code. This adjustment eliminated the gaps between rows and ensured that all video thumbnails align neatly from top to bottom. For any beginners facing a similar problem, including this line of code might just do the trick!

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

Make the minimum height of one div equal to the height of another div

My query is somewhat similar to this discussion: Implementing a dynamic min-height on a div using JavaScript but with a slight twist. I am working on a dropdown menu within a WordPress site, integrated with RoyalSlider. The height of the slider div adjust ...

Overrides of variables are not always complete

After setting up my project with npm install to utilize sass overrides, I encountered an issue. Despite adjusting the $theme-colors, only part of the page reflects the change. https://i.sstatic.net/xjrsx.png I attempted the following: $theme-colors: ("p ...

Is it possible to showcase a FullCalendar event in full width while being positioned behind other events scheduled for the same time slot?

Is there a way to customize FullCalendar so that concurrent events in the same timeslot are not vertically divided? I have a Google calendar named "time-blocking template" where I want all events to take up 100% of the timeslot width, even if there are ot ...

CSS hover effect ceases to function after the button has been clicked once

I am facing a dilemma with styling that I can't seem to resolve. There is a basic toggle feature on my page with two options -- the user can select either Toggle1 or Toggle2, resulting in different data being displayed dynamically based on the active ...

Utilize ngClass for every individual section

I have completed the implementation of all UI components, which are visually appealing. https://i.sstatic.net/hxJQr.png Here is the data structure I am using: public filters = [ { tag: 'Year', label: 'ye ...

Discovering phrases and adjusting the hue

Is there a way to change the color of text output by the ECHO function using CSS and conditions? For instance: If I use the ECHO function to display text like this: echo ": The net value of the entire order" echo ": The gross value of the entire order" ...

The thickness of an SVG line increases as it is rotated

I am working with multiple straight lines and have specified the stroke-width as 4. However, when I attempt to rotate them, the lines appear thicker than expected. Additionally, setting a negative value, such as <path d="M0 -10 20 0" stroke-width="4" st ...

The battle of line-height versus padding for achieving vertical centering with one-lined text

One-lined text can be vertically centered using either the line-height property or by adding padding-top and padding-bottom. What are the advantages and disadvantages of each method? body { font-size: 12px; font-family: ...

What is the correct CSS2 selector syntax to apply the :hover effect to the nth child of a specific element?

My goal is to apply a unique background color to each menu li element when hovered over, and I want to accomplish this using CSS2. <ul> <li> <li> <li> <li> </ul> I managed to add a background color to t ...

What could be causing my modal to not animate from the center of the screen?

I am aiming to have my .modal div class smoothly scale from 0 to 1 right in the center of the screen instead of starting at the bottom right and then moving to the center before settling in its final position. I have checked various resources like MDN docu ...

Challenges with the efficiency of hover effects

I have a div with a background image and inside that div, there is a component called Hero. I want to add a simple hover effect on a div with a className newBigButton. However, the transition is laggy when the background image is present. Here's the c ...

How can a CSS class be used to toggle the visibility of a DIV element with JavaScript?

I've been researching and came across several scripts that allow for toggling the contents of a DIV by clicking on a button, however, they all use IDs. What I am looking to achieve is similar but using classes instead of IDs. This way, if I want to h ...

Update: Explored 0 web pages (at a rate of 0 pages per minute) and obtained information from 0 elements (at a rate of

I'm a beginner in Python and Scrapy, currently working on my first project to crawl web security information from a website. However, when I try to run it using cmd, I encounter the message "Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 item ...

Display or hide a div element when hovering over it, while also being able to select the text within

I am trying to display and conceal a tooltip when hovering over an anchor. However, I want the tooltip to remain visible as long as my cursor is on it. Here is the fiddle link $('#showReasonTip').mouseover(function(){ $(this).parent().find(&apo ...

Applying CSS rules from an array to elements by looping through

I'm looking for a way to allow users to input CSS styles and have those styles applied to the last selected element, which is determined by the "rangeselector" variable. Currently, the code selects the correct element, but only the first CSS rule is b ...

Background and border presentation issues arising from CSS conflict

While working on a webpage, I encountered a design conflict within a div that contains a group of other div elements. The current appearance can be seen at , and the desired look is shown in the image here: enter image description here ...

Tips for customizing the appearance of an HTML dropdown menu

Here is the code snippet: <select name="xyz" id="abc"> <option value="x">10/Page</option> <option value="y">20/Page</option> <option value="z">30/Pa ...

HTML underlay with interactive z-index functionality

Is it possible to create an interactive Google Map with a frame image displayed? <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <input type="button" onclick="$('#frame_image').show();" val ...

Personalize the hover effect of CardActionArea

I'm attempting to personalize the hover effect of material-ui's CardActionArea for a specific component in my React application. Unfortunately, I am struggling to locate detailed documentation on how to style it effectively. Even after experimen ...

Modify/Adjust/Move the image uploaded by the user in VueJS before transferring it to an aws s3 bucket

Can you resize images in vuejs using vanilla js? I've managed to upload an image and send it to my s3 bucket using vue, but I'm struggling to figure out how to transform an image within vuejs and display it. Document.querySelector doesn't se ...