Questions tagged [responsive-images]

Responsive-images is the part of Responsive Web Design (RWD) dealing specifically with images on the web to provide optimal experiences across a wide range of devices based on screen size, platform, and orientation.

518 questions
99
votes
9 answers

100% width background image with an 'auto' height

I'm currently working on a mobile landing page for a company. It's a really basic layout but below the header there's an image of a product which will always be 100% width (the design shows it always going from edge to edge). Depending on the width…
Darryl Young
  • 2,145
  • 2
  • 20
  • 19
43
votes
4 answers

Why does width and height of a flex item affect how a flex item is rendered?

An image in a flexbox that has a max-height style appears to render differently depending on whether it has its height and width attributes set. The one with the attributes, set to the true width/height of the image, renders with its aspect ratio…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
28
votes
10 answers

bootstrap 4 img-fluid does not change image height

Responsive Images in Bootstrap 4, with class .img-fluid are resized disproportionally. They keep it's height even width is shrinking down correctly. That is deforming whole image. Is there any way how to make it as smooth as it was in Bootstrap 3…
Igor Mizak
  • 1,088
  • 1
  • 11
  • 19
23
votes
1 answer

does the element in html5 make the "alt" attribute obsolete?

Working on a portfolio for a photographer / videographer and trying to find a good balance between fast load and good image quality on mobile devices. So far, I'm keen to bet on the picture element to load multiple versions of the images based on…
Nelu
  • 351
  • 2
  • 7
23
votes
1 answer

image is not resizing in a flexbox layout

I tried to follow the advice in this answer, and as shown in this CodePen, but the image that needs to flex is still keeping its original dimensions unless the screen is so narrow it is alone on the row. There is another set of divs in the real…
kim holder
  • 1,744
  • 3
  • 16
  • 25
15
votes
2 answers

Get the current image source of a picture element

An HTMLImageElement has a currentSrc property so we can get the current source of an img element. Useful when defining multiple possible sources with srcset. There seems to be no equivalent for an HTMLPictureElement. Is there another way we can find…
Colin Meinke
  • 173
  • 1
  • 1
  • 7
12
votes
1 answer

Use Of the Sizes Attribute for Reponsive Images

I'm in the process of trying to wrap my head around using srcset and sizes on img tags. Whilst I think I have grasped the basics – mainly thanks to this article – I'm struggling in practical application of the sizes attribute. In all the examples I…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
11
votes
4 answers

Fade in background-image once it loads (no jquery) while still using media queries to replace images for different screen sizes

I've been reading all night and can't seem to come to any sort of concrete answer on what the best way to do this is. The two things that I know do work are these— For fading in an image when it loads: Use an image wrapper and an tag like…
shan
  • 3,035
  • 5
  • 34
  • 50
10
votes
1 answer

Css --webkit-image-set() syntax doesn't work for Chrome

I want to use .avif and .webp for images on my website, remembering that I need provide fallback for unsupported browsers. Docs https://developer.mozilla.org/en-US/docs/Web/CSS/image/image-set()#using_image-set_to_provide_alternative_formats suggest…
Sonny D
  • 897
  • 9
  • 29
10
votes
3 answers

versus ?

I can't seem to discern a difference in function or meaning between using the picture element or just using the img element with the srcset attribute. I understand how they work; I just don't fully understand why or when to choose one over the…
9
votes
2 answers

Bootstrap 4 carousel not responsive images

Look at this: http://www.consultacultura.it/portale_comunale_della_cultura.asp?IDcomune=1 Carousel images are not responsive like images under of it. They have the same class img-fluid.
Sergio
  • 93
  • 1
  • 5
9
votes
2 answers

Is it compulsory to use the sizes attribute with w-descriptors in srcset?

I have read through a number of articles on using srcset for both device-pixel-density adjustments as well as art direction: The State of Responsive Images in 2015 by Paddi Macdonnell srcset Part 2: The W descriptor and sizes attribute by Rich…
HubCap
  • 323
  • 5
  • 14
8
votes
1 answer

How to debug responsive images' srcset & sizes, like which media condition applies?

So yet again I find myself pulling my hair over responsive images. The CMS gives me its srcset, I build a simples sizes attribute, I check the currentSrc by hover-fumbling over the attribute in Dev Tools– wrong Src! Go to 10, change a media…
kubi
  • 829
  • 2
  • 14
  • 24
7
votes
3 answers

How to check if the browser supports AVIF images

How can I detect if the browser supports AVIF images using JavaScript? I have viewed this question and after reading the answers I was able to build a useful one-liner function to check browser support for various image types. const isSupported =…
7
votes
4 answers

bootstrap 5 responsive iframe keeping 16-9 ratio

I have read many post and tried everything to make the iframe responsive and keeping the 16-9 ratio... it is not bad but the video is still cropped in the youtube frame. What is the trick with bootstrap 5?
Paul Godard
  • 1,055
  • 1
  • 14
  • 30
1
2 3
34 35