Height of responsive image

how to put the height of the images when i get responsive the image is not be its actual place what should i do for responsive look???

Can you show us what you have so far? Do you have a codepen (or something similar) that you can give us a link to?

Also, you can google ā€˜css responsive imagesā€™ to find a ton of articles on how to do this but Iā€™ll save you the trouble and link to a good article.

1 Like

https://codepen.io/sunny-roy-the-vuer/pen/gOmpKmeā€¦

Respected Sir, This is the link of my documentā€¦I have not put any Responsive Property in this cssā€¦Acutally,the Issue that iā€™m facing that the header image which is at line 10in css and banner image which is in 90line in cssā€¦ when i minimize thereā€™s gape between the header image and banner imageā€¦Kindly resolve my issue Please ā€¦And tell me how to put the image height for responsive with example.Kindly,Sirā€¦Thank Youā€¦! @bbsmooth

Iā€™m not sure I understand completely, but if you want the height of the background image in the header to be responsive then you just need to add another 100% to the background-size:

background-size: 100% 100%;

Now as to whether you should do this? Well, give it a try, make sure to change the height of your browser from really short to really tall. Iā€™m not sure the woman in that pic will appreciate being put on the rack like that :slight_smile:

1 Like

For mid-sized viewports/tablets, this could work:

#header {
	width: 100%;
	height: 40vw;
	background-image: url("https://i.ibb.co/gmpr5cS/header.jpg");
	background-size: cover;
	background-repeat: no-repeat;
}

So, setting the background-size to ā€œcoverā€ and adjusting the height depending on the width. This wonā€™t work for smartphones, though. For narrow viewports. maybe something like this:

#header {
	height: 90vh;
	background-size: cover;
    background-position:top right;
}
2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.