I'm developing something similar to a Kanban board where I lay out cards (represented by divs) in columns (also represented by divs). Image 1 illustrates the current state of my app:
Each card is a div. The cards are grouped in columns (red dotted lines) which are divs laid out in flexbox layout. Coloring illustrates which release a card is mapped to.
Some code: index.html:
<!doctype html>
<html>
<head>
<title>Some code to copy & paste into your project</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="map">
<div class="column">
<div class="card release-1"></div>
<div class="card release-2"></div>
<div class="card release-3"></div>
</div>
<div class="column">
<div class="card release-1"></div>
<div class="card release-1"></div>
<div class="card release-3"></div>
<div class="card release-3"></div>
</div>
<div class="column">
<div class="card release-2"></div>
<div class="card release-2"></div>
<div class="card release-3"></div>
<div class="card release-3"></div>
</div>
</div>
</body>
</html>
styles.css:
.map {
display: flex;
flex-direction: row;
}
.column {
display: flex;
flex-direction: column;
}
.card {
width: 100px;
height: 80px;
border: 1px solid black;
margin: 10px;
}
.release-1 {
background-color: #f90;
}
.release-2 {
background-color: #0a0;
}
.release-3 {
background-color: #0af;
}
Now I'd like to add swimlanes for the releases. The result should look like this:
I didn't find any way to put something like "breakpoints" into the flex columns to move the cards to the next swimlane.
Grid would work but I need to know how many columns and swimlanes I will have beforehand. As the map is rendered dynamically, I would need to render the css dynamically as well. Doesn't look like the best approach to me :-P
Quite obvious this could be done with html tables, but there's two reasons that keep me from using them:
- Back in the days when floating layouts based on divs and css replaced table layouts, I learned that tables should only be used for data, not for layouts
- My whole layout is already based on divs. Switching to tables would require major efforts which I'd like to avoid
What speaks in favor of tables is the fact, that it would be really easy to achieve this layout with tables. I also don't expect any negative side effects as this layout isn't meant to float or break anyways. It's just two fixed dimensions and everything outside the viewport will be scrolled.
Anyways: before I re-write everything, I would like to know if this might as well be achieved with flex/flexbox layout or any other way I haven't heard of yet.
Right now I'm using no fronted framework, just plain html & css. I'd like to keep it that way if possible.
Do you have any suggestions?
Thanks in advance! Fred