admin管理员组文章数量:1243190
So I'm trying to make the image fits on my screen on all zooms e.g., like when u use google chrome zoom, so when zoom is at 80% The image fits well like the following image
but once I put my zoom at 100% this, there's a part that isn't covered by the image
My html code is the following
<article></article>
and css is the following:
article{
display: flex;
width: 100%;
height: 100vh;
background-image: url("/Assets/Choose-role-image.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}
What should I do to make the image fits on all zooms,should I change the height or remove it or what do you suggest as a solution
I have added some borders so you see what Im talking about enter image description here Thanks in advance
So I'm trying to make the image fits on my screen on all zooms e.g., like when u use google chrome zoom, so when zoom is at 80% The image fits well like the following image
but once I put my zoom at 100% this, there's a part that isn't covered by the image
My html code is the following
<article></article>
and css is the following:
article{
display: flex;
width: 100%;
height: 100vh;
background-image: url("/Assets/Choose-role-image.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}
What should I do to make the image fits on all zooms,should I change the height or remove it or what do you suggest as a solution
I have added some borders so you see what Im talking about enter image description here Thanks in advance
Share Improve this question edited 2 days ago Omar asked Feb 17 at 15:31 OmarOmar 93 bronze badges 7- Can you create a snippet inside your question and upload the image to a publicly available source so we could play around the problem in order to help you? – Lajos Arpad Commented Feb 17 at 15:45
- You can never guarantee to get all of an image into a space with no gaps of course as aspect-ratios may differ. What you can do is look into sizing values such as cover and contain and decide what is best for your application. – A Haworth Commented Feb 17 at 16:12
- @LajosArpad I will try to do that right now – Omar Commented Feb 17 at 16:44
- @LajosArpad stackblitz/edit/… PLEASE CHECK THIS OUT ALSO IS THERE ANYWAY i CAN CONTACT WITH YOU ? – Omar Commented Feb 17 at 17:02
- @AHaworth so there's no solution ?? also how big companies manage to do such thing and they got good image for each screen size even if you zoom in/out it still appears perfect – Omar Commented Feb 17 at 17:04
1 Answer
Reset to default 0Try using the background-size property with the value 'cover'. The code should look like this:
article {
display: flex;
width: 100%;
min-height: 100vh;
background-image: url("/Assets/Choose-role-image.png");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
本文标签: htmlTrying to make Image fits on differents zoomsStack Overflow
版权声明:本文标题:html - Trying to make Image fits on differents zooms - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740146994a2231963.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论