I'm attempting to create a custom 'iTunes' style expanding layout. However, I am hitting a few issues. I had originally anticipated using flex-box for this. But I can't quite seem to do what I am looking to do.
I've attached an image of what I am trying to create. Essentially a grid of clickable thumbnails with expanding content which is full width. And the full width aspect is what I am struggling with. Am I going to have to set an explicit width on the expanding content or will it be possible for the content to flex to full width?
What I'm trying to create:
I've attached a very basic codepen that demonstrates the issue I am having. If the first image was 'expanded' I would want it full width.
.album-container {
display: flex;
flex-direction: row;
}
.album {
width: 50%;
}
img {
width: 100%;
}
.expanded-content {
background: #212121;
color: #FFFFFF;
}
<div class="album-container">
<album class='album'>
<img alt="album-artwork" src="https://img.discogs.com/grVTPVqiRonKp5ly_ey-moBmO0c=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-11826116-1524151283-4015.jpeg.jpg">
<div class="expanded-content">
<div>Whatever People Say I Am, That’s What I’m Not</div>
<div>Arctic Monkeys</div>
</div>
</album>
<album class='album'>
<img alt="album-artwork" src="https://img.discogs.com/grVTPVqiRonKp5ly_ey-moBmO0c=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-11826116-1524151283-4015.jpeg.jpg">
</album>
</div>
https://codepen.io/jakefauvel/pen/QoKdJP
If you want to keep exactly this HTML structure, and have only one popover at a time, This approach could help you(see snippet)
But I think it would be better and cleaner to restructure HTML code, for example, move your .expanded-content
out from .album-container
and change it's content with JavaScript if possible.
.album-container {
display: flex;
flex-direction: row;
position: relative;
}
.album {
width: 50%;
}
img {
width: 100%;
}
.expanded-content {
background: #212121;
color: #FFFFFF;
position: absolute;
left: 0;
width: 100%;
}
<div class="album-container">
<album class='album'>
<img alt="album-artwork" src="https://img.discogs.com/grVTPVqiRonKp5ly_ey-moBmO0c=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-11826116-1524151283-4015.jpeg.jpg">
</album>
<album class='album'>
<img alt="album-artwork" src="https://img.discogs.com/grVTPVqiRonKp5ly_ey-moBmO0c=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-11826116-1524151283-4015.jpeg.jpg">
<div class="expanded-content">
<div>Whatever People Say I Am, That’s What I’m Not</div>
<div>Arctic Monkeys</div>
</div>
</album>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With