question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set max height for gallery container

See original GitHub issue

I have many photos and they are in different orientations (some are in horizontal and some are in vertical) in different gallery sets (all photos in gallery almost always has a horizontal or a vertical orientation). Wide images is almost look fine with default settings but tall images look awful image I can’t understand how to set max-height for gallery container. .image-gallery {max-height: 400px} do nothing at all.

If I set .image-gallery {width: 500px} it will affect to fullscreen mode and made it useless and width property affecting wide photos which become very tiny.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
ivarnecommented, Feb 5, 2018

I think i solved a similar problem with

.image-gallery-content:not(.fullscreen) .image-gallery-image {
  width: 100%;
  height: 0;
  padding-top: 75%; /* Make the image wrapping div take a ratio of 3:4 */
  position: relative;
  img {
    position: absolute;
    top: 0;
    object-fit: cover;
    object-position: center center;
    width: 100%;
    height: 100%;
  }
}
2reactions
xiaolincommented, Mar 13, 2017

You shouldn’t need that. You can nest css classes.

.image-gallery {
  // regular css.
  width: 400px;
}

.image-gallery.fullscreen {
  // your full screen css
  width: 600px;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

max-height - CSS: Cascading Style Sheets - MDN Web Docs
The max-height CSS property sets the maximum height of an element. It prevents the used value of the height property from becoming larger ......
Read more >
Image with max-width, and set height - Stack Overflow
Using a container with a max-width allow us to have the right width, then using height on the image allow the image to...
Read more >
CSS max-height property - W3Schools
Definition and Usage. The max-height property defines the maximum height of an element. If the content is larger than the maximum height, it...
Read more >
set autoheight to gallery control - Power Platform Community
There is no auto-height for the gallery itself - the height of the gallery control is fixed. However, you can use what we...
Read more >
Max-Height - Tailwind CSS
Set the maximum height of an element using the max-h-full or max-h-screen utilities. <div class="h-24 ..."> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found