|
|
Thread Tools | Display Modes |
|
#1
|
|
|
Smug Hero
|
Stretchy Background Image
So I was working with someone on their site today who wanted to have a single image stretch to fit whatever browser window. After some tinkering I found a rather simple way to make this work. (until CSS 3 is implemented in all browsers that is)
In your CSS: Code:
#bgImg {
position:fixed;
width:100%;
height:100%;
top:0;
left:0;
z-index:-1;
}
In the Body Tag: Code:
<img src="www.imageurl.com/photo.jpg" id="bgImg" /> Last edited by Smug Eric; Mar-14-2013 at 12:48 PM. Reason: The test page was changed |
|
|
|
|
#2
|
|
|
Beginner grinner
|
Hi, how about the gray background behind the slideshow? I can't get rid of it. http://itsdouet.com
Thank you for your help! |
|
|
|
|
#3
|
||
|
Major grins
|
Quote:
__________________
Nick Photographer: Katherine Stathes Web Designer: USMC Cpl Coffman, Nicholas J http://www.stathesquo.smugmug.com |
|
|
|
||
|
#4
|
|
|
Major grins
|
Eric,
I only wanted this on my home page and certain categories. I came up with this to make it work, but is there a cleaner or easier way to do this? /* Background */ #bgImg { position:fixed; width:0%; height:0%; top:0; left:0; z-index:-1; } .homepage #bgImg { position:fixed; width:100%; height:100%; top:0; left:0; z-index:-1; } .category_Football #bgImg { position:fixed; width:100%; height:100%; top:0; left:0; z-index:-1; } .category_Basketball #bgImg { position:fixed; width:100%; height:100%; top:0; left:0; z-index:-1; }
__________________
http://millerpics.smugmug.com/ |
|
|
|
|
#5
|
|
|
Smug Hero
|
you could do this instead:
#bgImg { display: none; } .homepage #bgImg, .category_Football #bgImg, .category_Basketball #bgImg { display: block; position:fixed; width:100%; height:100%; top:0; left:0; z-index:-1; } |
|
|
|
|
#6
|
|
|
Major grins
|
Yep, that looks much better. My solution seemed to be asking for problems.
Thanks,
__________________
http://millerpics.smugmug.com/ |
|
|
|
|
#7
|
|
|
Major grins
|
FYI, I expanded on the above to allow for the customization of the background on individual Share pages. With this, by changing the url in the Share description, you can make the background of each share different. In the Share Description I put something like;
<img src="your url here" id="sharebg" /> Add <HTML> tags if required Shares without anything like this in the description are unchanged from the default. Then I added the following to CSS; #sharebg { display: none; } .shareHomepage #sharebg { display: block; position:fixed; width:100%; height:100%; top:0; left:0; z-index:-1; } Customization of Share Groups is not easy, but this may help. Larry
__________________
http://millerpics.smugmug.com/ |
|
|
|
|
#8
|
|
|
Major grins
|
Here is a link to one I'm working with;
http://millerpics.smugmug.com/share/Video The description for this Share Group is as follows; <html> <img src="http://millerpics.smugmug.com/photos...-5tXzScW-L.jpg" id="sharebg" /> <center><img src="http://millerpics.smugmug.com/photos.../i-VGsmM96.png" height="133" width="743"></center> <BR> <div id="navcontainer4"> <ul> <li><a href="/"><font color=#ffffff><strong>Miller Home Page</strong></font></a></li> <li><a href="http://millerpics.smugmug.com/Other/...6_EXr7m"><font color=#ffffff><strong>Jordan Family Photos</strong></font></a></li> <li><a href="http://millerpics.smugmug.com/Other/...7_BVRUW"><font color=#ffffff><strong>Secure Galleries</strong></font></a></li></ul> <BR> </div> </html>
__________________
http://millerpics.smugmug.com/ |
|
|
|
|
#9
|
||
|
Big grins
|
Quote:
I am trying this and I typed this into the Body Tag (the green type is the name of the image): <img src="www.dclphoto.com/image2.jpg" id="bgImg" /> Nothing appeared to happen, so I tried this in the Body Tag: <img src="www.dclphoto.com/photo.jpg" id="bgImg" /> Neither is creating a full spread of the image across my screen. Any suggestions as to what I am doing incorrectly? |
|
|
|
||
|
#10
|
|
|
Smug Hero
|
You need the actual url of the image. Go into the gallery you have uploaded it to. Select the Share ~> Get a Link option and get the largest one there. Paste that into the quotations.
|
|
|
|
|
#11
|
|
|
Big grins
|
Thank you! That did work, but it only stretched my image horizontally. Is there a way to stretch it and keep in in proportion to avoid distortion of the image?
|
|
|
|
|
#12
|
|
|
Smug Hero
|
I'm not seeing the code for it on your site.
|
|
|
|
|
#13
|
|
|
Big grins
|
|
|
|
|
|
#14
|
|
|
Major grins
|
Keep in mind that as the viewer changes the size of the browser window the image will distort - unless Eric has a different method to try here. You can see that by changing the size of the window using the sample link from the first post.
--- Denise
__________________
http://www.denisegoldberg.com ... http://denise.smugmug.com Musings & ramblings at http://denisegoldberg.blogspot.com, quick posts in google+ |
|
|
|
|
#15
|
||
|
Big grins
|
Quote:
OK. So is there a way to enlarge the background image and have it accomodate according to the browser? If not, I will just leave it as is. Wasted space on the side gutters is the better of two evils I guess. |
|
|
|
||
|
#16
|
|
|
Smug Hero
|
I've only seen the fixed size or the stretchy hack I came up with here. But if you don't want it to distort you can choose to remove either the width: 100%; or height: 100%; lines. If the code is only expanding it on one dimension then they could be some blank space at the bottom or at the sides of the page depending on which you remove. But with that the image would not distort.
|
|
|
|
|
#17
|
|
|
Big grins
|
You, Denise and the whole SM crew rock! Denise, I did a little tweaking in photoshop to allow for some stretch and increased pixel size. I'm not sure how well it help, the largest monitor I have is 17'. Thank you guys for your help. My light bulb clicked on too. What if I wanted to put a .gif? I tried with one my test vids and it loaded, but didn't play. I'm a real dummy when it comes to code, but I have downloaded the 50 page CSS tut. Thank you all for sharing what code you have written.
Again, you guys rock! Chad |
|
|
|
|
#18
|
|
|
Major grins
|
I used this code on my site but the image is shown as a 'header' instead of as a background image.
I took out the image url for now. Here is my site: www.wallacehuo.info |
|
|
|
|
#19
|
||
|
Big grins
|
Got it, but now dropdown fails.
Quote:
Elan
__________________
www.capturessencephotography.com |
|
|
|
||
| Tell The World! | |
| Similar Threads | Thread Starter | Forum | Replies | Last Post | ![]() |
| How To Maximize Your Findability (Search Engine Stuff) | Andy | SmugMug Support | 1039 | Jun-18-2012 05:30 AM | |
| Correcting Chromatic Aberration in Adobe Camera Raw 5.6 - a few suggestions | pathfinder | Grad School | 3 | Jun-17-2011 01:34 PM | |
| Photographic Terms: A - L | ivar | Tutorials | 0 | May-25-2011 12:08 PM | |
| Professonional Photoshop, Chapter 8: Keeping the Black and White in Color | mwgrice | Finishing School | 7 | Feb-13-2007 11:58 AM | |
| Chapter 11 - Retouching in LAB - Late and Incomplete | pathfinder | Finishing School | 12 | Mar-18-2006 08:12 AM | |
| Thread Tools | |
| Display Modes | |
|
|