/    Sign up×
Community /Pin to ProfileBookmark

How do you make a background image fit different resolutions

I have an image that I put on the back of a theme and it fits perfectly on my 19″ monitor with 1280 x 1024 resolution But my other computer with a 17″ monitor and 1024 x 768 resolution doesn’t look right and the image is clearly too large. The right hand side film strip is completely missing.

Here is a screen shot of what it is supposed to look like.

[URL=http://i307.photobucket.com/albums/nn318/feistycritic/FeistyCritic.jpg][IMG]http://i307.photobucket.com/albums/nn318/feistycritic/th_FeistyCritic.jpg[/img][/URL]

Here is a screen shot of what it is doing on 1024 x 768 resolution and I am sure on other resolutions it looks just as bad.

[URL=http://i307.photobucket.com/albums/nn318/feistycritic/FeistyCritic2.jpg][IMG]http://i307.photobucket.com/albums/nn318/feistycritic/th_FeistyCritic2.jpg[/img][/URL]

Any idea how to make this work right? I have been searching all day and I don’t know php very well so I really need some specific help on this one.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 23.2008 — Rather than a PHP solution (if there is one), I'd recommend breaking the "film strip" portions of the image into separate images which can be used as separate backgrounds in a 3-column layout with fixed-width outer columns (holding the film strips) and a fluid middle column for the page content.

To dynamically change the size of a background image, you'd probably need to use a bunch of JavaScript to determine the current window width, then update the background image by requesting the image from a PHP file that would dynamically re-size it based on a supplied value in the url or post data. However, if we're talking about a 1280x1024 image, we're talking about using up a lot of memory on the server each time the image is requested, due to PHP image functions processing images as bitmaps, which can use quite a lot more memory that a JPEG, GIF, or PNG file of the same dimensions.

Alternatively, and more efficient if not quite so flexible, would be to have several versions of the image on the site in different dimensions, then have JavaScript code which selects the most appropriate image for the current window size. This would not require any PHP.
Copy linkTweet thisAlerts:
@SassMcGauthorApr 23.2008 — Rather than a PHP solution (if there is one), I'd recommend breaking the "film strip" portions of the image into separate images which can be used as separate backgrounds in a 3-column layout with fixed-width outer columns (holding the film strips) and a fluid middle column for the page content.[/QUOTE]

This sounds like a feasible plan I think. I am definitely not experienced enough to figure out how to do javascript code without a lot of help. But I do understand what you are saying above there. So let me see if I understand this correctly.

I would need to have a left film strip and a right film strip and then a fluid middle. Then in the style sheet I would code it to place the left strip on the left and right on right and then do what for the middle? I am not sure what code to use for any of that but it makes sense. ?
Copy linkTweet thisAlerts:
@NogDogApr 23.2008 — Here's a fairly simple solution:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled 1&lt;/title&gt;
&lt;style type="text/css"&gt;
html, body {
margin: 0;
padding: 0;
height: 100%;
}
#container {
padding: 0 190px 0 0;
background: white url(http://www.charles-reace.com/image/noggin.jpg) repeat-y 100% 0;
height: 100%;
}
#main {
margin: 0;
padding: 0 10px 0 200px;
background: white url(http://www.charles-reace.com/image/noggin.jpg) repeat-y 0 0;
height: 100%;
}
/* IE6- hack */
* html #container {
height:100%
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="container"&gt;
&lt;div id="main"&gt;
&lt;h1&gt;Test Page&lt;/h1&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.&lt;/p&gt;
&lt;p&gt;Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.&lt;/p&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.&lt;/p&gt;
&lt;/div&gt; &lt;!-- main --&gt;
&lt;/div&gt; &lt;!-- container --&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@SassMcGauthorApr 23.2008 — I am doing all this within a php forum stylesheet so I am not sure where to put that. I don't think I need ALL that do I? ?
Copy linkTweet thisAlerts:
@NogDogApr 23.2008 — It's just a sample page to show a method of laying out the page. Move the stuff in the <style> block to your CSS stylesheet, and replace the "Lorem Ipsum" text within the <div id="main"> . . . </div> to whatever you want to actually output. (And of course adjust the stuff in the style section to use your images, desired colors, widths, etc.)
Copy linkTweet thisAlerts:
@SassMcGauthorApr 23.2008 — I found another way of doing it but now what I wonder is if there is a way to make two separate images, one on the left and one on the right both show up in their positions. So basically two background images that do not repeat.
×

Success!

Help @SassMcG 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.18,
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,
)...