icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old August 30th, 2007, 10:46 PM   #1 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
CSS Background question

Can't seem to remember exactly, and tried a bit of a search, but no luck yet.

I'm trying to use CSS (in body {}) to display the background image stretched 100% in size and glued to the bottom, with no image repeat.

Anyone got the solution? Thanks.
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 30th, 2007, 10:54 PM   #2 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,055 posts
Gave thanks: 48
Thanked 129 times
Actually, there is no way to scale an image specified with background-image in the current spec. You'll see background-size in CSS3.

The current suggested methods are to use conditionals (read: media queries which aren't well supported) or to use an img element absolute/fixed positioned, behind everything else (z-index).
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks H for this great post!
GamingHybrid (August 31st, 2007)
Old August 30th, 2007, 11:12 PM   #3 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
true, I think I found another way, but it might now work. I'm trying it atm.
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 30th, 2007, 11:30 PM   #4 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
Apparently it won't I guess I'll just wait for CSS3 then :P The site itself is interactively heavy, so too much patching would be more of a issue than solution.

No wonder couldn't remember, since it can't be done. Thanks H.
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 31st, 2007, 12:03 AM   #5 (permalink)
Surpass Fan
Excelling Contributor
 
cowboy's Avatar
 
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
934 posts
Gave thanks: 2
Thanked 94 times
Make your initial page and get your viewable window size using:

<script language="JavaScript">
var width = screen.width;
window.location = 'index.php?width=' + width;
</script>

Immediatly redirecting to a PHP page with:

<?PHP
$width = $_GET['width'];
// resize your master image to the width with GD if needed
if (!exists 'master'.$width.'.jpg') {
// resize, save, and keep that image
}
?>
<style>
body {
background: url(master<?=$width?>.jpg;
etc;
}
</style>
__________________
Where would you be if you were at the highest court in the land (US)?
cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks cowboy for this great post!
GamingHybrid (August 31st, 2007)
Old August 31st, 2007, 1:57 AM   #6 (permalink)
Bow before Surpass!
Super #1
 
Joined in Sep 2004
1,544 posts
Gave thanks: 91
Thanked 49 times
Quote:
Originally Posted by cowboy View Post
Make your initial page and get your viewable window size using:

<script language="JavaScript">
var width = screen.width;
window.location = 'index.php?width=' + width;
</script>

Immediatly redirecting to a PHP page with:

<?PHP
$width = $_GET['width'];
// resize your master image to the width with GD if needed
if (!exists 'master'.$width.'.jpg') {
// resize, save, and keep that image
}
?>
<style>
body {
background: url(master<?=$width?>.jpg;
etc;
}
</style>
Naw, not really what I was looking for. i just wanted something that would stretch the image itself, but not pick a image name.

Thank you though
__________________
GamingHybrid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 31st, 2007, 4:24 PM   #7 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,055 posts
Gave thanks: 48
Thanked 129 times
Hmm. I don't like the proxy to PHP so much. You'd be just as well off to use JavaScript to choose a background image (obviously start off with a default, in the event they don't have JavaScript enabled).
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 6th, 2007, 2:26 PM   #8 (permalink)
Senior Member
Super #1
 
FredFredrickson's Avatar
 
Joined in Nov 2003
Lives in New Hampshire
1,220 posts
Gave thanks: 3
Thanked 22 times
Execpt the PHP example is platform independent. And javascript is dumb. When you can avoid javascript, do.
__________________

Surmunity Special-Free Photos To Season Your Site/Blog, Code: fallatsurpass

Last edited by FredFredrickson; September 6th, 2007 at 2:28 PM. Reason: I can't think good.
FredFredrickson is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 6th, 2007, 11:27 PM   #9 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,055 posts
Gave thanks: 48
Thanked 129 times
You're putting load on your server, slowing the request for the image AND depending on JavaScript in the first place (how do you think you're getting the height of the window?).

JavaScript is not dumb and far from it. If done properly, people that don't have JavaScript enabled shouldn't really notice.

Doing it properly in this case would be creating a background image that will work for your average visitor (either by meeting the lowest significant resolution or the most common). That will be specified in your CSS file that is loaded by everyone. Then using JavaScript, probably triggered onload, you'll use DOM to find the element and replace the background image.
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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