Results 1 to 5 of 5

 

Thread: Background image stretch?

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Jan 2006
    Posts
    159
    Thanks
    4
    Thanked 0 Times in 0 Posts


    Hi, I am trying to find out whether, if I use a background image, it's possible to have the image stretch to the resolution of the viewers browser. I have tried using:

    background:url(RosesBgd02.jpg) no-repeat center;

    with the css but it only centers the image - The image is currently 800x600 so therefore any browser over this has a nasty border around the background picture. I know that I can put a background colour but I would prefer to not have this, and have the image stretch to the edges. Any clues please?

    My HTML isnt great so please in english terms

    Thanks in advance

  2. #2
    Paul Wright's Avatar
    Fishboy

    Status
    Offline
    Join Date
    Jan 2005
    Location
    London
    Posts
    1,735
    Thanks
    32
    Thanked 20 Times in 14 Posts
    Hiya, unfortunately the css background property doesn't take height/width dimensions so there's no quick fix for this one. The only way i can think of is to set the image within a div tag then change the z-axis so it sits behind your content. I would check browser compatibility though as this is a bit of a cheap hack.

    You could try something like this I guess.
    Code:
    <div style="width: 100%; height: 100%; left: 0px; top: 0px; position: absolute; z-index: 0;">
    <img src="image.jpg" style="width: 100%; height: 100%;">
    </div>
    Always better to resize the image in an art package though so you're starting off with the correct proportions.

    Cheers
    Paul.
    Agency Services Director | e: paul.wright@tradedoubler.com | t: 0207 798 5825


  3. #3
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    I think the only way you could do it would be by using the JavaScript onResize() function.

    I have got round it on a site I am designing for a customer by using an <img src="whetever.jpg" width="90%"> tag. This site look similar in all screen sizes from 1600 *1200 to 640 * 480

    View the source to get some ideas.

    bob

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    661
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could use some kind of screen resolution detection script, then load the appropriately sized background image through a stylesheet.


    By the way the bbc have some kind of background image magic going on.
    http://www.bbc.co.uk/bbctwo/

  5. #5
    Registered User

    Status
    Offline
    Join Date
    Jan 2006
    Posts
    159
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks for the responses, knew you'd have the answer.

    I will have a play about with all the options and see what works out best.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Image URL's in datafeeds
    By B1gJo3 in forum Affiliate Marketing Lounge
    Replies: 12
    Last Post: 14-10-07, 05:45 PM
  2. dynamic image problem
    By pricethat in forum Programming
    Replies: 3
    Last Post: 26-07-05, 11:35 PM
  3. Mouseover on sections of an image
    By Wardy in forum Programming
    Replies: 9
    Last Post: 21-03-05, 05:33 PM
  4. Replies: 5
    Last Post: 17-12-04, 11:39 AM
  5. durr im thick, css & image borders
    By morleymouse in forum Programming
    Replies: 5
    Last Post: 02-09-04, 10:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2