/    Sign up×
Community /Pin to ProfileBookmark

scaling a background image

is it possible to scale a background image in css or html?? when i say scale I mean… lets says my background image was a 1280×1024 but if someone was viewing the web page at a resolution of 1024×768 the background would scale down to that size. is that possible?

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelJul 29.2007 — Yes. You want an image that is given width:100% and height:100%, centered in the page, and give the body, html {width:100%;}.

There might be a detail to be included, but it is do-able. check Stu Nicholls' site "cssplay", -I am sure that I saw something like that there.
Copy linkTweet thisAlerts:
@MrMJSauthorJul 29.2007 — perfect.. thank you for your help
Copy linkTweet thisAlerts:
@CentauriJul 29.2007 — The Stu Nicholls' link to that demo is http://www.cssplay.co.uk/layouts/background.html - not actually a css background, but an image within a div to emulate a background.
Copy linkTweet thisAlerts:
@ray326Jul 29.2007 — Of course it's really better to find a different kind of solution using a background image of a defined size because letting the browser resize the image to fit will guarantee in most cases a crummy looking image.
Copy linkTweet thisAlerts:
@WebJoelJul 31.2007 — I much prefer a static-sized image, centered. And if OP wants it, -I have a javascript snippette that determines the client's current screen-width and translates this to re-size the image. I don't think it does this for 'backgrond-image' but if the image is opaque and light, some clever z-index -ing could make the content rise above the image..

If user has javascript turned off/or doesn't have it, -the 'centered, non-resizing is at least 'downward degradeable'.
×

Success!

Help @MrMJS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...