/    Sign up×
Community /Pin to ProfileBookmark

CSS Backgrounds

Is there any way, in CSS or otherwise, to have your background automatically size it self to the browser window? I would of course make its attachment fixed, then the background would always be completely visible, no matter what resolution is viewing it.

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzNov 09.2005 — No, unfortunately CSS2 does not provide a way to specify or modify the dimensions of background images.
Copy linkTweet thisAlerts:
@The_Little_GuyNov 09.2005 — No not with CSS, but I just got a reply on something like this In Javascript:
<i>
</i>&lt;script type="text/javascript"&gt;

document.onload=pickIt()
function pickIt()
{
var w=screen.width
var h=screen.height
if(w==1024&amp;&amp;h==768)
{
document.getElementsByTagName('body')[0].style.backgroundImage="url('URL OF SMALLER BACKGROUND IMAGE')";
}
else if(w==1152&amp;&amp;h==864)
{
document.getElementsByTagName('body')[0].style.backgroundImage="url('URL OF LARGE BACKGROUND IMAGE')";
}
}
&lt;/script&gt;


Just fill in the areas with the code.

[B]Note[/B]: You Will Need one image for each

[B]Note[/B]: You may need to restart your browser when you change resolutions while on the internet.
×

Success!

Help @nstiesi 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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