|
-
Jan 16th, 2006, 01:31 PM
#1
[RESOLVED] CSS Stretch Background image?
is there a way to have a centered Background image stretch according to screen size?
this doesnt work 
Code:
body {
background-image: url('bg_main.jpg');
background-repeat: no-repeat;
background-position: center;
background-width: 100%;
background-height: 100%;
background-color: black;
}
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 16th, 2006, 01:59 PM
#2
Re: CSS Stretch Background image?
nevermind.. found out u cant.... have to create a layer and stretch that.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 23rd, 2006, 10:26 PM
#3
New Member
Re: [RESOLVED] CSS Stretch Background image?
HOw do you do it with a layer?
I'm gueesing
Code:
<layer background="MemDayFlag.jpg" height="100%" width="100%">
and am trying this as I ask.
-
Jun 24th, 2006, 04:14 AM
#4
Re: [RESOLVED] CSS Stretch Background image?
There is no such thing as a layer in HTML. There's no way to stretch a background image.
-
Jun 25th, 2006, 07:05 AM
#5
Re: [RESOLVED] CSS Stretch Background image?
It's usually done by faking the background. You place the image in a div (which is what he probably meant by layer :cringe: ), and then stretch the div.
Code:
#divbg {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 0; <------------Notice!
}
#maincontent
{
z-index:1; <--------------Notice!
position:absolute;
}
Then in your HTML,
Code:
<div id="divbg"><img src="abc.jpg" width="100%" height="100%"/></div>
<div id="maincontent">all text here</div>
-
Jun 25th, 2006, 04:46 PM
#6
New Member
Re: [RESOLVED] CSS Stretch Background image?
 Originally Posted by penagate
There is no such thing as a layer in HTML. There's no way to stretch a background image.
Yeah that's old HTML.
-
Jun 26th, 2006, 02:37 AM
#7
Re: [RESOLVED] CSS Stretch Background image?
Nothing new really, but just to show how a CSS expert has done it:
http://www.cssplay.co.uk/layouts/background.html
-
Jun 26th, 2006, 07:46 AM
#8
Re: [RESOLVED] CSS Stretch Background image?
Layer was the wrong choice of words... sorry 
basically I need an image to cover the screen... and always center so if u were 800x600 the logo would still be in the middle....
Code:
<style type="text/css">
body {
background-image: url('bg_main.jpg');
background-repeat: no-repeat;
background-position: center;
background-color: black;
cursor: hand;
scrollbar-arrow-color: black;
scrollbar-base-color: black;
scrollbar-dark-shadow-color: black;
scrollbar-track-color: black;
scrollbar-face-color: black;
scrollbar-shadow-color: black;
scrollbar-highlight-color: black;
scrollbar-3d-light-color: black;
}
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 5th, 2012, 05:52 AM
#9
New Member
Re: [RESOLVED] CSS Stretch Background image?
In modern browsers you can now use the CSS3 property background-size
Code:
.selector {
/* will stretch the image so that it covers all of the element */
background-size: cover;
/* will stretch the image so that it fits perfectly inside the element */
background-size: contain;
}
This allows to achieve background stretching while preserving the aspect ratio of the background-image: https://developer.mozilla.org/en-US/...ackground-size
I’ve personally developed a polyfill that implements those properties in IE8: https://github.com/louisremi/background-size-polyfill
-
Dec 12th, 2012, 11:58 PM
#10
New Member
Re: [RESOLVED] CSS Stretch Background image?
Thanks for the useful info, its really helped me out too 
 Originally Posted by mendhak
It's usually done by faking the background. You place the image in a div (which is what he probably meant by layer :cringe: ), and then stretch the div.
Code:
#divbg {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: absolute;
z-index: 0; <------------Notice!
}
#maincontent
{
z-index:1; <--------------Notice!
position:absolute;
}
Then in your HTML,
Code:
<div id="divbg"><img src="abc.jpg" width="100%" height="100%"/></div>
<div id="maincontent">all text here</div>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|