#I was suffering from a very strange behavior about <img> element

8 messages · Page 1 of 1 (latest)

worldly granite
#

I've set this image's width property to 100% in css
and save and refreshed the mini browser for many times, but the image was still not 100% to the screen. But after the challenge the teacher writes almost the same code except for class's name and he gets the wanted image size. We were using the same platform. This is way to surreal! I've copied my code below.

<img class="sneaker-image" src="images/sneakers-purple.png" alt="Purple and silver sneakers">
.sneaker-image{
    width: 100%;
}
rare flame
#

Can you share the entire Scrim? The width property fills the image to it's parent size and we can't see that here.

worldly granite
#

😳 I found where goes wrong. This challenge solution doesn't include the image element's parent's padding, which I added in the very beginning. But the early version wasn't saved due to some reason I couldn't remember. And I do remember I didn't get the wanted result in the version which included the padding may be due to network problem.

#

Sorry, everyone🙇‍♂️

worldly granite
rare flame
# empty sage for images use maxwidth:100%

Hmmm... that depends entirely on what you want to happen. If you use max-width instead of width then the image will stop growing if it's own width is < the container's width... this may or may not be what you want.