Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responsive image height overflow #34885

Closed
cdalexndr opened this issue Sep 2, 2021 · 5 comments
Closed

Responsive image height overflow #34885

cdalexndr opened this issue Sep 2, 2021 · 5 comments

Comments

@cdalexndr
Copy link
Contributor

cdalexndr commented Sep 2, 2021

While using .img-fluid, if the image height is larger than the container's , then the image can overflow:
image

Codepen: https://codepen.io/cdalxndr/pen/gORMGPE

Also, it would be nice for the docs should include samples for all types of image sizes:

  • width too large
  • height too large
  • both too small
  • both too large

Bootstrap 5.1.0
OS: Win10 19043
Browser: Firefox 90.0

@cdalexndr
Copy link
Contributor Author

The following seems to fix it:

.img-fluid{
  object-fit:contain;
  height:100%;
}

@mdo
Copy link
Member

mdo commented Sep 6, 2021

Implementing something like that might not be the best solution for everyone, so we don't use it by default. Definitely an add-on individual developers and designers should choose to use :).

@mdo mdo closed this as completed Sep 6, 2021
@cdalexndr
Copy link
Contributor Author

Seems bad that responsive images are broken by default...

@mdo
Copy link
Member

mdo commented Sep 7, 2021

They're not broken by default, they specifically are designed to keep the aspect ratio of an image while preventing it from being too wide. There's no assumption of scaling an image based on a fixed height container. Changing to include additionally properties would potentially break images for everyone else.

@cdalexndr
Copy link
Contributor Author

cdalexndr commented Sep 7, 2021

Then docs should be changed to reflect this.

From docs: ...responsive behavior (so they never become larger than their parent elements)

From the above statement I understand that a responsive image is expected to not have a height greater than it's parent (larger than their parent ), but this is incorrect as I demonstrated.

Docs should be changed to reflect that only width is taken into account.

cdalexndr added a commit to cdalexndr/bootstrap that referenced this issue Sep 8, 2021
mdo pushed a commit that referenced this issue Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants