Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 06:27:15 PM

Pages: [1]   Go Down
  Print  
Author Topic: repeat img in HTML, not css  (Read 2781 times)
Brennie369
Galactic Royalty
*****
Offline Offline

Posts: 202



WWW
« on: August 28, 2010, 10:27:34 AM »

Hi, I am currently working on converting one of my sites from fixed to fluid layout. The design incorporates an image which is why I never tackled this before,  but I found a way to make the image adjust according to the viewers window size. I was happy to discover that!

However, I am now having a problem with an aspect I thought would be simple. There is a div which is for a column, & in the html code the div starts with an image, which is the one I successfully got to adjust.  Also in this column div in my css is a background image, which is set to repeat-y (vertically).  I have tried to figure out how to make this background image to not repeat but to stretch in the css (to adjust to wider resolutions), with no luck. So I am thinking my only way is to add the image in the html doc instead of the css doc, but I can't figure out how to make it repeat vertically.

Here's my test page I'm working on: http://www.brenniesdreamscape.com/test.html
The column in question is the 3rd (right-most), which has the top image & the gradient image below, which is currently called for in the css as a background image & set to repeat-y.  This is the one I'm working on, as when I view in higher resolutiobns, it repeats. I don't want it to repeat (horizontally), I want ot to stretch.
« Last Edit: August 28, 2010, 10:37:11 AM by Brennie369 » Logged
MrPhil
Berserker Poster
*****
Offline Offline

Posts: 5083



« Reply #1 on: August 28, 2010, 12:24:29 PM »

You're talking about background images? Frankly, I've never seen any way to make one stretch/squeeze to fit a given size (as you can with foreground images). Maybe something like that will come down the line in HTML5 or something, as it would be useful, wouldn't it? I can understand why this hasn't been done, as greatly scaled images usually look pretty bad, and sending over megapixel images to be scaled down a little isn't good use of bandwidth. The usual practice is to make an image a full gradient in one direction, and tile it in the other, to fill the background. Or, send a very large image and only show the upper left corner on most screens. Either way, use a compatible background color to fill any gap between the image and the larger space to fill. That's all I've ever seen done.

Something I've never tried, but might work, would be to send a foreground image and then place everything else over it with a higher z-index. That way, the image (fake background) could be scaled to 100% width and/or 100% height. Don't forget to use a background color to fill any gap. Just a thought.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: