How do i stretch my background image 100%

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

How do i stretch my background image 100%

Post by adsegzy »

Hello Friends,

I need to use an image as a background, but i dont want it to repeat horizontal or vertical. i want it to stretch 100% horizontal, pls how do i do this?

regards
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: How do i stretch my background image 100%

Post by PHPHorizons »

Hello adsegzy,

I'm assuming you're looking for a css related answer here (Board index » Design » HTML, CSS and other UI Design Technologies).

There are proprietary background stretch css rules but they are not standardized across the main/popular browsers. Therefore, you cannot stretch background css images in a cross browser way at this time.

You could just put in an HTML IMG Element and apply a % width/height to it. But you would have to position your content on top of that image, and is not a natural way to do a website, at all...

You could host multiple bg images of different sizes. Then you can use javascript to detect the users screen width, and set the bg image to suit.

The best option though, and I know no one likes to be told not to do the thing they want to do, is to change your design so that you can avoid the need for a stretched background image since browsers just are not designed to cope with such a thing very well at all at this time.

Cheers
Post Reply