It is hard to explain what i exactly want so i’ll post some images.
image
So i want the tracks to get align side by side vertically when they pass the album covers height.
li elements are dynamically generated by the js code. I created an array of objects and it passes the tracks.
Here’s my html and css code. Thanks in advance im going crazy over this and it seems something so easy to do.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="">
<title>What</title>
</head>
<body>
<main>
<div class="album-container">
<img src="" class="cover">
<div class="album-info">
<div class="title-info">
<h2 class="title">Title</h2>
<h3 class="artist">Playboi Carti</h3>
<span class="year">Year</span>
</div>
<ul class="tracks">
<!--
li tags gon be dynamically created by script
-->
</ul>
</div>
</div>
<button class="btnChange">Look</button>
</main>
<script src="./app.js"></script>
</body>
</html>
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c&display=swap');
img{
max-width: 400px;
max-height: 400px;
}
*{
box-sizing: border-box;
margin: 0;
padding: 0;
text-decoration: none;
list-style-type: none;
font-family: 'M PLUS Rounded 1c', sans-serif;
overflow: hidden;
}
body{
background-color: #0a0908;
color: white;
height: 100vh;
}
main{
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
ul{
display: flex;
flex-direction: column;
flex-wrap: wrap;
max-height: 400px;
}
li{
padding: 5px;
}
.album-container{
margin-bottom: 20px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.album-info{
margin-left: 20px;
flex: 1;
}
.btnChange{
clear: both;
}
2
Answers
This is actually not an easy problem to solve.
My suggestion would be to use a grid for the overall layout, then for the track list use an absolutely positioned nested flexbox with the following styles:
flex-direction: column
flex-wrap: wrap
align-content: start
The absolute positioning is necessary in order to have the height of the second column be determined by the height of the image in the first column, rather than the contents of the
<ul>
.Here is a snippet to demonstrate:
Use a two-column grid for the list of tracks. This is all I changed: