+ 3

Regarding Height in CSS

So I have an image, and i have in CSS what follows below Img{ Width:100%; Height:100px; } Now i would like to change the height to a percentage so when it's viewed on a smaller screen it still looks good but everytime i do so, even just 5% it takes up the whole screen, whats up with this, and is there a workaround? https://code.sololearn.com/WVuPm3F5Hu92/?ref=app

15th Jun 2019, 9:59 PM
StealthyTaco
StealthyTaco - avatar
7 odpowiedzi
+ 4
https://code.sololearn.com/WtCxdVu4R82u/?ref=app
16th Jun 2019, 2:29 PM
Calviղ
Calviղ - avatar
+ 27
.
17th Jun 2019, 5:58 PM
Tushar
Tushar - avatar
+ 5
To make an image display in its proper respect ratio. You should set img with the width in % and height in auto. Eg. img { width: 100%; /* or other value */ height: auto } If the height set to 100%, the image would be distorted likely.
15th Jun 2019, 11:33 PM
Calviղ
Calviղ - avatar
+ 3
You can use media queries and specifying the height of the image
15th Jun 2019, 10:36 PM
Trinity
+ 2
Can you please provide the code? We can't find out anything about this situation with just a description
15th Jun 2019, 10:05 PM
Airree
Airree - avatar
+ 1
I added my code now so you guys can see
16th Jun 2019, 1:47 PM
StealthyTaco
StealthyTaco - avatar
+ 1
Try making it a background-image css property, you can have more control with scaling than with regular images.
17th Jun 2019, 9:30 PM
BlazingMagpie
BlazingMagpie - avatar