Goal: make a scrollable image-gallery web-component. Make the Layouting work without script-intervention.
Requrements:
- the size of the web-component has to be fully responsive and/or adjustable.
- the top main area of the widget is the gallery - it is mainly a flex-row container where different images reside horizontally. The user can scroll freely to the left and right.
- the webcomponent has to have a bottom area with some info about the current image. This area has to be of a fixed size [e.g. in px].
- thus, the gallery area has to scale vertically.
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
Observation Firefox: Screenshot of the f#in Problem
Versions used in the Screenshot: Chrome[v69], Firefox[v63]
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
<style>
body {
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto 50px;
height: 150px;
}
.container1 {
overflow-y:hidden;
display:flex;
}
.container2 {
background-color: green;
}
img {
height: 100%;
object-fit: scale-down;
align-self: stretch;
}
</style>
<body>
<div class="container1">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=350">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=350">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=350">
</div>
<div class="container2">Must retain height of 50px</div>
</body>
Observation Chrome: Got it to work on chrome too, BUT now it's not working on Firefox ... Chrome likes, when the images are wrappet in divs.
<style>
body {
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto 50px;
height: 150px;
}
.container1 {
overflow-y:hidden;
display:flex;
}
.container1>div{
align-self: stretch;
}
.container2 {
background-color: green;
}
img {
height: 100%;
object-fit: scale-down;
}
</style>
<body>
<div class="container1">
<div><img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=350"></div>
<div><img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=350"></div>
</div>
<div class="container2">Must retain height of 50px</div>
</body>