I'm trying to create a layout (which will be a music player) with flex.
I have 3 buttons (previous, play, and next, represented by the red squares) which I always want to be on the same line.
I then have some song info (current time, song title, and total time) that I want to display to the right of the buttons.
I pretty much always want the total time to be on the far right and for the song title to fill up the remaining width (with flex-grow
), but to truncate with ellipsis as the window gets smaller.
Does anyone have any idea how to tweak this to get it to work properly?
.wrapper {
display: flex;
align-items: center;
}
ul {
display: inline-block;
list-style: none;
flex-shrink: 0;
}
li {
display: inline-block;
width: 30px;
height: 30px;
background: red;
margin-right: 3px;
}
.song-wrapper {
background: beige;
display: flex;
flex-grow: 1;
}
.song-title {
background: blue;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex-grow: 1;
}
<div class="wrapper">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<div class="song-wrapper">
<span>1:23</span>
<span class="song-title">This is the song title and I want it to ellipsize if the screen shrinks</span>
<span>4:22</span>
</div>
</div>