Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Background Resize


7 replies to this topic

#1 ExplosioN

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 31 July 2005 - 01:21 PM

Does anyone have the javascript for a background to resize? I want my background to resize to 1024x768 if the visitor has resolution 1024x768, to 800x600 if the resolution is 800x600 etc.

Greets,
ExplosioN :D

#2 ExplosioN

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 31 July 2005 - 01:49 PM

oh I forgot to add, is it possible to make limits on it? Like the image won't resize anymore if the resolution is smaller then 800x600?

#3 truefusion

    Coincidence is non-sequitur, therefore everything has a reason for its existence (except if they are eternal).

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,216 posts
  • Gender:Male
  • Location:No, not there. Not there either. Yes, you'll never figure it out.
  • Interests:God, Christianity.
  • myCENT:86.16

Posted 01 August 2005 - 01:45 AM

I think you can do it w/o javascript. Just make one for 1024x768, but make it so if it were to be seen in 800x600, it wouldnt be noticable. I've seen it done before. The layout would have to be aligned to the left, while the background would take care of the right side.

#4 Tyssen

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,161 posts
  • Location:Brisbane, QLD

Posted 01 August 2005 - 02:22 AM

You can't resize the background image, it'll only display at its full size, but you can serve up different images based on the browser size.
Use My Google to find a script that works for you.

#5 iwuvcookies

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 697 posts
  • Gender:Male
  • Interests:like i'm gonna tell you. Hey what are you doing in my profile???lol.
  • myCENT:51.28

Posted 01 August 2005 - 03:10 AM

If you find the site could you please tell me to as I would like to know how to do this too. I'll join the search for this script too.

#6 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 02 April 2009 - 05:36 AM

Here is the answer that has evaded you X2! Your welcome.Background Resize

There iare numerous ways this can be done.  Make sure on either method to change the image to your background of course.  Here are two different ways I just happen to have in my documents at the moment:

<script language="JavaScript1.2">

if (document.All||document.GetElementById)Document.Body.Style.Background="url('YourIMG.Jpg') white center no-repeat fixed"

</script> 

As you probably figured the script goes at the start of your body (inside of the body tags of course).

This is actually ment to give you a watermark effect so your background doesnt scroll but it will also work for your resizing issue. Here is another way to do it using div's:

<div style="position:absolute; width:100%; height:100%; margin:0px; padding:0px; left:0px; right:0px;z-index:1"> <img src="YourIMG.Jpg" width="100%" height="100%"></div>

<div style="z-index:2; position:absolute; margin:0px; padding:0px; height:100%; width:100%; overflow:scroll;">

<p>&nbsp;</p> <p>THIS IS THE CONTENT</p>

</div>

-reply by Eric Backer

 



#7 kleong

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 509 posts

Posted 04 April 2009 - 10:05 AM

I dont remember coming across a javascript that enable to you to detect the screen resolution. I would like to know if there is one. As suggestion, why not create a website with a liquid width? In that case, you need not worry abt the screen resolution of your users.

#8 Guest_RWF_*

  • Guests

Posted 11 July 2010 - 03:45 PM

View Postkleong, on 04 April 2009 - 10:05 AM, said:

I dont remember coming across a javascript that enable to you to detect the screen resolution. I would like to know if there is one. As suggestion, why not create a website with a liquid width? In that case, you need not worry abt the screen resolution of your users.

Hey there,

you don't actually need a specific code to detect resolution you can just put it in an if/else clause

if((screen.width==1280)&&(screen.height==800)) document.write('<style type="text/css">body {background:url(http://.jpg);background-attachment: fixed;}"></style>')

hope this helps




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users