What is causing the misalignment of the flexbox items on the right side?

Why do the green buttons inside the flexbox on the right-hand side not evenly occupy the height of the flexbox?

[JSFiddle URL: https://jsfiddle.net/example/123] (https://jsfiddle.net/example/123)

<!DOCTYPE html>
<html lang="en">
<head>
  <link href="example.css" rel="stylesheet"/>
</head>
<body>

  <div class="container page">

    <div class="leftPanel">
    </div>

    <div class="midPanel">
      <img class="section-image" src="example.jpg"/>
    </div>

    <div class="rightPanel">
    <div class="flex1">
    <div class="rightPanelItems">

      <div class="rightPanelButton">
        <a href="#">Example 1</a>
      </div>

      <div class="rightPanelButton">
        <a href="#">Example 2</a>
      </div>

      <div class="rightPanelButton">
        <a href="#">Example 3</a>
      </div>

      <div class="rightPanelButton">
        <a href="#">Example 4</a>
      </div>

    </div>

    </div>
    </div>
  </div>

</body>
</html>
* {
  font-family: Arial, Helvetica, sans-serif;
}

html, body {
  margin: 0;
  border: 0;
  padding: 0;
  background-color: #ffffff;
}

.page {
  margin-left: auto;
  margin-right: auto;
  margin-top: 0;
  margin-bottom: 0;
  background-color: #ffffff;
  width: max-content;
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
}

.leftPanel {
  width: 25vw;
  height: 100%;
}

.midPanel {
  width: max-content;
  height: max-content;
}

.section-image {
  width: 50vw;
  height: auto;
}

.rightPanel {
  display: flex;
  width: 25vw;
  height: inherit;
  background-color: blue;
}

.flex1 {
  flex: 1 0 auto;
  height: inherit;
  background-color: red;
}

.rightPanelItems {
  display: flexbox;
  flex-direction: column nowrap;
  justify-content: center;
  background-color: yellow;
  height: 100%;
}

.rightPanelButton {
  background-color: darkolivegreen;
  margin: auto;
  flex: 1 0 auto;
}

.rightPanelButton > a {
  color: white;
}

Answer №1

There seems to be a typo in your code. You have used display: flexbox, but it should be corrected to display: flex.

Here is the corrected code snippet:

.rightPanelItems {
  display: flex;
  flex-direction: column nowrap;
  justify-content: center;
  background-color: yellow;
  height: 100%;
}

To improve spacing, you can update it further by using justify-content: space-between.

.rightPanelItems {
  display: flex;
  flex-direction: column nowrap;
  justify-content: space-between;
  background-color: yellow;
  height: 100%;
}

.rightPanelButton {
  background-color: darkolivegreen;
  margin: auto;
}

I have made the necessary changes by replacing justify-content with space-between and removing flex: 1 0 auto; from .rightPanelButton.

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

JavaScript Issue: Unable to Update or Delete Table Row Data

Presently, I am involved in developing a project titled : Tennis Club Management using a blend of Javascript, HTML, CSS, and Bootstrap. This project encompasses several HTML pages and a JS file such as index.html, profile.html, manageFees.html, index.js, e ...

Assign the IP address to the hostname for resource loading in HTML

One way to assign an IP address to a hostname for asset loading without relying on DNS resolution. For example: set the IP of host.com to 1.2.3.4 <img src="http://host.com/img.png"> <img src="http://host.com/img2.png"> <script type="text/j ...

What is the best way to incorporate an HTML button that triggers the execution of a PHP script?

Is there a way for me to create an HTML button that can retrieve the value of this specific URI? https://example.org/qrcodes/qrcode.php?user= As a beginner in PHP, I'm not sure how to go about implementing this. Within the PHP file named grcode.php ...

What are some effective strategies for avoiding empty fields showing on an email form?

My HTML form is linked to a PHP Email handler, and it's working well except for one issue. When the email is delivered, it includes all fields, even the empty ones. I want it to only display filled-in fields. I tried using an IF statement that checks ...

Guide on how to display the header of GridView on every printed page

Is there a way to include the page title and GridView header on each printed page? I am looking for a solution to display the page title and GridView heading on every printout. While using page breaks to split the GridView across multiple pages, I notice ...

Conceal the menu by pressing the button

I'm having trouble with a bootstrap drop-down feature. When the button is clicked, the menu appears, but clicking the button again doesn't hide the menu as intended. I've attempted a method that didn't work and I believe there must be a ...

Implement the addition of a class upon hovering using AngularJS

My goal is to include a new class when hovering over the li element using Angular in the code snippet below. <li ng-mouseenter="cola-selected=true" class="pull-left" ng-class="{'selected' : cola-selected}"> <a href="interna.html"> ...

Adjusting the position of the parent div by manipulating the bottom property

Is there a way to toggle the bottom property of a div when clicking its child anchor tag? <div class="nav" :class="{ 'full-width': isFullWidth }"> <a class="toggle-button" @click="toggleNav"><i class="fa fa-angle-down">< ...

Having trouble with innerHTML.value functionality?

Recently, I've been delving into creating a JavaScript program that fetches Wikipedia search results. Initially, everything seemed to be working fine as I was able to display the searched item using the alert() method. However, for some reason, it now ...

Expand the functionality of XHTML by incorporating namespaces

I remember coming across this concept somewhere, but I can't recall the exact source. I am interested in expanding HTML tags to include my own attributes on the HTML elements. I remember seeing an example where a developer added a new xmlns to the pa ...

JavaScript doesn't have the ability to access constants across different scripts

Despite its apparent simplicity, I am encountering an issue where I cannot access the auth variable between index.js and auth.js. Whenever I try to do so, I receive an error stating that auth is not defined in auth.js. My initial assumption was that placin ...

Switch between visibility of objects with toggle button

I have set a background image on the body, and positioned a large box, footer, navigation bar, and header above it. In order to add functionality to slide these elements up and down, I've created two buttons with classes 'slideUp' and &apos ...

Display or conceal all sections based on selected dropdown options within the Elementor plugin

I have a dropdown menu with 9 different sections underneath 1. Section id=Hige x 3 2. Section id=Medium x 3 3. Section id=Low x 3 My goal is to show only the sections that correspond to the selection made in the dropdown menu. I am using jQuery to achi ...

Creating a full-width row and columns layout using CSS Flex Box styling

Hello my fellow coding enthusiasts! I'm trying to create a simple box layout using flexbox, but I'm struggling to get it just right. The goal is to have a row with two columns within one container. Here's what I'm aiming for: Essentia ...

"Enhance Navigation: Sublevel Dropdowns with the Power of Twitter

Here is a link to my fiddle: http://jsfiddle.net/xkXdy/ I am trying to create submenus for the dropdown input box in my project. Currently, it only shows the category, but I want it to display subcategories when hovered over. The dropdown functionality wo ...

Creating a JavaScript button for text capitalization: A step-by-step guide

Is there a way to modify this script so that users are required to click a button in order for all text entered into the form to be converted to uppercase? I understand that the onclick function needs to be utilized, but I am uncertain about where and ho ...

When a user clicks on a button, AJAX and jQuery work together to initiate a setInterval function that continually

Currently, I have two scripts in place. The first script is responsible for fetching a specific set of child nodes from an XML file through AJAX and using them to create a menu displayed as a list of buttons within #loadMe. What's remarkable about thi ...

Issue with Slick Slider loading incorrectly within a hidden container

The title says it all. I am currently working on a website using a single HTML file, where different pages are represented by div elements that toggle between display:none and display:block based on an onclick function. On one of these pages, I want to in ...

`Trouble with CSS Measurement Properties in Internet Explorer 10`

(In the past, I relied on conditional IE statements to exclude a portion of my website from IE Browsers. Unfortunately, this method is no longer supported in IE10.) Currently, I have three images displayed on the header of my site, stacked one on top of t ...

Exploring the world of real-time search functionality using jQuery for instant suggestions

I have a live search feature with jQuery on my website. The search works fine and displays results, but when I click on a result, I want the value to be shown in my input field. Additionally, once I click outside of the input field, the result should hide ...