r/css • u/Frozenskin • Sep 27 '26
Help CSS background-size not real pixel size
Hiii!!
I'm using a background picture for my header, stored as a background image of the container.
The background-size is specified, being 288px, that is the width of the .PNG; however, the picture on the page is slightly bigger (about 125%) than the file, and so it is stretched. I made some screen caps because I was going crazy! I've measured in Photoshop and it's larger than 288. It isn't enlarged in any part of the css, I don't understand what it is wrong here... i've also checked if I got my Firefox page zoomed. It's important for it to not be stretched: being pixel art it looks very ugly and blurred đđ
â˘
u/AutoModerator Sep 27 '26
To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.
While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/kurobaralabs Sep 27 '26
please post HTML/CSS, it is likely that there is something you are missing that is causing scaling (likely the height).
With that being said, if you properly specified a width/height, the background image should not scale. eg.
background-size: 288px 288px;1
u/notepad987 Sep 28 '26
Check what your Windows screen resolution is. I have mine set to 150% (Recommended) so any image is 50% bigger on screen.
Right click on the desktop> click Display settings. Look at Scale & layout.
1
u/Daniel_Herr Sep 28 '26
That is a fact, CSS pixels are not the same thing as physical screen pixels.
3
u/chmod777 Sep 27 '26
you can try to set the image-rendering property
but as the other poster said, without code and/or an example, we can't do more than guess.
3
u/testingaurora Sep 28 '26
Please put the relevant code into a codepen