HighDots Forums  

background-image getting cut off outside original window display

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss background-image getting cut off outside original window display in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KNDesign
 
Posts: n/a

Default background-image getting cut off outside original window display - 12-15-2006 , 11:23 PM






I've set a background image to repeat-y and at 100% height. It appears
fine when I open the window, but when I resize to a smaller height so
that I must scroll down to see the rest, the background image is
suddenly gone from the bottom.

#background {
position: absolute;
top: 0px;
bottom: 0px;
left: 50%;
margin-left: -370px;
background-image: url(images/background.gif);
background-repeat: repeat-y;
width: 740px;
height: 100%;
}

see here: http://www.kndesign.net/index2.htm

I've tried turning off the background repeat but that doesn't seem to
work (although it's not shown in the css, just have to trust me that I
tried it). Can anyone help? I'm fairly new to this so the answer may be
obvious to everyone else.


Reply With Quote
  #2  
Old   
KNDesign
 
Posts: n/a

Default Re: background-image getting cut off outside original window display - 12-15-2006 , 11:26 PM






A few edits here: the no-repeat fix IS in the css so you don't have to
trust me. Also, the subject says original window display but that's not
accurate, it's basically showing the background at the size of the
window and anything taller than that is cut off at the bottom.


Reply With Quote
  #3  
Old   
Ben C
 
Posts: n/a

Default Re: background-image getting cut off outside original window display - 12-16-2006 , 07:12 AM



On 2006-12-16, KNDesign <kndesign (AT) gmail (DOT) com> wrote:
Quote:
I've set a background image to repeat-y and at 100% height. It appears
fine when I open the window, but when I resize to a smaller height so
that I must scroll down to see the rest, the background image is
suddenly gone from the bottom.

#background {
position: absolute;
top: 0px;
bottom: 0px;
left: 50%;
margin-left: -370px;
background-image: url(images/background.gif);
background-repeat: repeat-y;
width: 740px;
height: 100%;
}

see here: http://www.kndesign.net/index2.htm

I've tried turning off the background repeat but that doesn't seem to
work (although it's not shown in the css, just have to trust me that I
tried it). Can anyone help? I'm fairly new to this so the answer may be
obvious to everyone else.
height: 100% means 100% of the viewport height. You might think that
would be recalculated if the viewport was resized, but it isn't in any
browser I know (and the CSS spec does say that 100% refers to an
"_initial_ containing block").

Really you want your background image to be the height of the body
element, not the height of the viewport.

So why not get rid of the background div altogether, and add to the body
selector something like this:

background-image: url(images/background.gif);
background-repeat: repeat-y;
background-position: center top;

By the way you have a dodgy comment at the top of your stylesheet
css.css

//* CSS DOCUMENT *//

that was causing the whole body selector to be rejected for me. Change
it to

/* CSS DOCUMENT */

Or better still just delete it altogether since it's not exactly a very
informative comment!

I'm not quite sure what you were up to with left:50%, margin-left:-370px
on the #background div anyway. background-position may be just as good
or better a way to position your background image.


Reply With Quote
  #4  
Old   
KNDesign
 
Posts: n/a

Default Re: background-image getting cut off outside original window display - 12-16-2006 , 09:07 AM



thanks for the help!

moving the background image and repeat-y to the body and centering it
fixed the problem. thanks for the note about the css comment, i don't
even know why it's in there and took it out.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.