Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 02-13-2005, 07:43 PM   #1 (permalink)
Fox
TSF Enthusiast
 
Fox's Avatar
 
Join Date: Sep 2002
Location: NJ
Posts: 7,752
OS: XP Pro, CentOS

My System

Send a message via ICQ to Fox Send a message via AIM to Fox Send a message via MSN to Fox Send a message via Yahoo to Fox Send a message via Skype™ to Fox
Making a background image fit multiple resolutions

Hi guys,

This has been driving me nuts for as long as I can remember. I would like to know how to make a background image stretch to fit higher resolutions and shrink to fit lower resolutions. Does anyone know how to do this? Or even know of a website that works this way?
Fox is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 02-13-2005, 10:48 PM   #2 (permalink)
Moderator
 
shuuhen's Avatar
 
Join Date: Sep 2004
Location: Colorado
Posts: 761
OS: Mac OS 9.1, Mac OS X 10.5.5, WinXP Pro, FreeBSD 6.0, Gentoo Linux


You could probably use JavaScript or PHP to check what the resolution of the screen is, then use variables to control what the image is scaled to when they see it.

Here's how to detect screen size with JavaScript.

PHP would probably be a better solution. I think you use the $_GET['width'] and $_GET['height'] variables to get the screen size.
shuuhen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 02-14-2005, 01:14 PM   #3 (permalink)
Fox
TSF Enthusiast
 
Fox's Avatar
 
Join Date: Sep 2002
Location: NJ
Posts: 7,752
OS: XP Pro, CentOS

My System

Send a message via ICQ to Fox Send a message via AIM to Fox Send a message via MSN to Fox Send a message via Yahoo to Fox Send a message via Skype™ to Fox
Any idea how to implement either of these things so that they'll work with my page?

Like for the javascript...could I use those values as variables, and have different resolutions of that picture available on the server depending on what it returns?

PHP's an option too...I just don't know enough to make either of these options happen on my own.

Thanks a lot
Fox is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 02-14-2005, 07:44 PM   #4 (permalink)
Moderator
 
shuuhen's Avatar
 
Join Date: Sep 2004
Location: Colorado
Posts: 761
OS: Mac OS 9.1, Mac OS X 10.5.5, WinXP Pro, FreeBSD 6.0, Gentoo Linux


This should work if you are ok with having a different copy of the image for each resolution.

Code:
<html>

<head>
<title>Resolution dependent background</title>
</head>

<body>
<script language="javascript">
if (screen.width >= 800 && screen.width < 1024)
{
        document.body.style.background="url('jscript_test.jpg')"
}
if (screen.width >= 800 && screen.width < 1024)
{
        document.body.style.background="url('jscript_test2.jpg')"
}
</script>
<p>Just to see if text works
</p>
</body>

</html>
I tested it with Firefox 0.10.1 on Yellow Dog Linux, Firefox 1.0 on Win98SE and IE 6 on Win98SE. All three combinations seemed to work fine.
shuuhen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 02-14-2005, 07:57 PM   #5 (permalink)
Fox
TSF Enthusiast
 
Fox's Avatar
 
Join Date: Sep 2002
Location: NJ
Posts: 7,752
OS: XP Pro, CentOS

My System

Send a message via ICQ to Fox Send a message via AIM to Fox Send a message via MSN to Fox Send a message via Yahoo to Fox Send a message via Skype™ to Fox
Thanks, will test it out tomorrow.
Fox is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 04:41 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82