Ensure that each column within a flexbox list is set to a flex-direction of column and flex-wrap of wrap, with a width no wider than

This code snippet is almost functioning correctly, but there seems to be an issue with it taking up the entire width available:

https://jsfiddle.net/d16ba2re/2/

CSS:

ul {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  height: 100px;
  padding: 0;
  margin: 0
}

li {
  background: white;
  border: 1px solid #ccc;
  list-style: none;
  padding: 0;
  margin: 0
}

The justify-content property doesn't seem to have any effect, regardless of how I adjust it.

Is there a simple solution to achieve the desired outcome here, or am I at a dead end?

Answer №1

It seems like you are interested in using the align-content property with a specific value, such as flex-start:

ul {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  height: 100px;
  padding: 0;
  margin: 0
}

li {
  background: white;
  border: 1px solid #ccc;
  list-style: none;
  padding: 0;
  margin: 0;
}
<ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
  <li>Five</li>
  <li>Six</li>
  <li>Seven</li>
  <li>Eight</li>
  <li>Nine</li>
  <li>Ten</li>
  <li>Eleven</li>
  <li>Twelve</li>
  <li>Thirteen</li>
  <li>Fourteen</li>
  <li>Fifteen</li>
  <li>Sixteen</li>
  <li>Seventeen</li>
  <li>Eighteen</li>
  <li>Nineteen</li>
  <li>Twenty</li>
  <li>Twenty one</li>
  <li>Twenty two</li>
  <li>Twenty three</li>
</ul>

Answer №2

If I decide to ask another question instead, but if this happens to be an easy query for you... I am facing challenges when using float:right to wrap . The expectation is for the div to fully contain the ul, however it actually overflows. Here is a link to a demo: jsfiddle.net/d16ba2re/3

Try setting a specific width for your div. I tested with 295px and it appears to work fine.

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

deleting the digits following the decimal point

When converting a string to decimal using Convert.ToDecimal() in the razor engine, I want the result to be rounded off to the nearest integer value. I have attempted to use Math.round, Math.ceil, and String Format, but so far none of them have been succes ...

Is there a peculiar issue with CSS float:right in IE9?

These are the styles I'm using: For the parent container: div.musicContainer { width:820px; height:54px; margin-bottom:20px; } And for the child containers: div.hardcorePlayer { width:400px; float:left; border:n ...

Styling columns to be inline-flex without taking up the full height

I'm currently working on a project similar to "Trello" or "Zenhub," using a Kanban board with 4 columns placed in a div#board. The columns are set to display: inline flex, creating a neat horizontal alignment. However, I encountered an issue where eac ...

Error message: "Maximum width header anomaly"

I've been working on a full-width header tumblr theme and everything looks great until I resize the screen to a smaller size, like on a mobile or tablet. The header ends up cutting off and no longer maintains its full width. You can see an example of ...

Unclear when notifying div content

After creating a PHP page, I encountered an issue while trying to select the inner text of a div and alert it with jQuery. Instead of getting the expected result, it keeps alerting "undefined." What could possibly be causing this? Here is the code snippet ...

Incorporate a pseudo class to a unique custom template or directive within an Angular project

I have been developing a custom dropdown menu directive in AngularJS. The issue I'm facing is that the buttons in my template become inactive when interacting with the dropdown menu, unlike a regular HTML select which remains active while the dropdown ...

CSS Adaptation of Hover Interaction

I'm currently developing a user interface using Shiny and I've been working on creating some visually appealing buttons. I've managed to customize the colors as desired, but now I'm facing an issue with getting the button to darken when ...

Attempting to establish a means to switch between languages

Currently, I am in the process of implementing a language switch feature for a website project that I am currently working on. This feature will allow users to seamlessly switch between English, Latvian, and Norwegian languages. To achieve this functionali ...

What is the best way to calculate precise pixel dimensions for mobile devices?

Upon inspecting the browser's developer tool, it indicates that the resolution of an iPhone X is 375*812, although this may not be the actual resolution. While CSS pixels do not always align perfectly with display resolution, the question remains - If ...

Transforming external JavaScript and CSS scripts into HTML code

I am attempting to consolidate an external JS file and CSS file into a single HTML file by incorporating them internally in the HTML. While the CSS is functioning correctly with the style tag, the JS file seems to be causing some issues. What adjustments ...

Experiencing difficulties in applying an image texture to a plane using Three.js CanvasRenderer

I'm currently working on creating a UI inspired by the Halo Reach menus. My plan is to set the webpage background to an image, create a plane in front of it, and use a texture with semi-transparent rectangle shapes as the main background for the UI. I ...

Accordion transition effect designed by yours truly

After creating an accordion using jquery and css, everything seems to be working fine except for the transition effect when collapsing. The collapse action is too fast, both when opening and closing. I am unable to apply a slower transition effect. Check ...

The CSS styles are not applied when using self.render("example.html") in Tornado/Python

I'm still learning Python and programming in general. I'm currently using Tornado as my web server to host my websites. However, when I try to generate a dynamic html page using self.render("example.html", variables here), the resulting page does ...

What is the best way to incorporate an image or custom shape into a divider?

I'm looking to replicate this unique divider design. Any suggestions on adding the leaves element to it? Is there a more efficient method than creating the border in photoshop, saving it as a jpg, and then linking it to the divider? The inner section ...

Is there a way to uncover the original source of a background image data?

I came across a website with an image that caught my eye. However, upon inspecting the source code with firebug, I discovered that it was not an actual image, but a div with the following CSS condition: background-image: url("data:image/gif;base64,R0lGODl ...

Creating a sleek Bootstrap inline form featuring two input fields with minimal spacing between them

I am working on a form using twitter-bootstrap with two inline input fields nested in two columns. I want to remove the padding between these inputs to achieve a specific layout. Here is an example of how I want my form to look: https://i.sstatic.net/aSh ...

The image on the card is barely visible due to the applied Bootstrap 4 styles

When uploading an image with a greater height and narrower width, it may appear distorted in the user cards on the website. Below are the HTML and CSS components used in our Angular framework: HTML <div class="container-fluid" > <div class="ro ...

Having difficulty reaching elements within a shadow frame using Selenium in Java

I am encountering an issue while trying to access an element within a shadow iframe. I am able to switch to the frame successfully, but when attempting to access elements inside it, I am getting a Stale Element Exception. Any assistance with this would be ...

How can I optimize webkit-mask-box-image with a high-resolution Retina image?

Hey there, wondering if it's possible to achieve high-quality Retina-level CSS masking with the -webkit-mask-box-image property. Specifically, I'm trying to round the corners of an element without using border-radius due to performance issues: . ...

The Bootstrap Navbar is occupying an excessive amount of room on compact screens

Currently, I am developing a responsive website using bootstrap 3. However, I am encountering an issue with the collapsed navbar. Instead of the normal height (i.e. height of one nav link item), it is taking up the total height of all the nav link items. Y ...