• marcmoss

    (@marcmoss)


    I’ve got a fixed background image that I’d like to display in all of my posts. I can get it to display, and it’s fixed like I need it to be, but it isn’t displaying properly. Here’s the image: http://ecobuildmontana.com/wp-content/uploads/2009/05/lucas_vein_381_301.jpg

    I can’t figure out why the image is displaying somewhat disjointedly. have a look at the page to see what I mean.

    http://ecobuildmontana.com

    See how it’s all off-center and seemingly split in half, the right side displaying on the left, the left side on the right, instead of the entire image displaying in one piece? Can anyone else who may have run into this offer any help?

    I’ve had a look at it in Opera, FF & IE7, and the issue is present in all 3 browsers.

    Much thanks.

    The code is:

    .post{
    	background-color: #f6fbe5;
    
    background-image: url(http://ecobuildmontana.com/wp-content/uploads/2009/05/lucas_vein_381_301.jpg);
    
    background-repeat: none;
    text-align:left;
    background-attachment: fixed;
    
    background-position: center;
    
    }
    
    .post_alt
    {
    
    background-color: #f6fbe5;
    
    background-image: url(http://ecobuildmontana.com/wp-content/uploads/2009/05/lucas_vein_381_301.jpg);
    
    background-repeat: none;
    text-align:left;
    background-attachment: fixed;
    
    background-position: center;
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • stvwlf

    (@stvwlf)

    hi

    you have the background image assigned in two classes, post and post_alt. On posts that are in both classes its displaying twice

    try putting the background image on class maincol instead
    you will probably need a repeat-y

    instead of center center, use percentages – start with 30% 0% (first is horizontal, second vertical) and adjust as needed

    Thread Starter marcmoss

    (@marcmoss)

    Thanks, stvwlf.

    I tried what you suggested, commenting out the code in post and post_alt, then putting it into maincol.

    The result was that the image spread across most of the page, encompassing the area where the navbar should be & kicking the navbar down to below the last post.

    Played with percentages, too, instead of center; center, played with the repeat setting, with no satisfactory results.

    I can definitely see, now that you point it out, I cannot have the same code in this case, in two classes, and I think you’re right, it should go into the maincol class. I’m just unsure of what settings to tweak there so that the image displays only once and the navbar stays where it should.

    Wish I could find an example of how this is being used successfully somewhere, so that I could look at the CSS there. So far, no luck on that.

    Can anyone else offer any suggestions?

    Thanks.

    Thread Starter marcmoss

    (@marcmoss)

    update: figured out why the navbar was moving. I was replacing the entire contents of the maincol class with the code I currently have in post.

    Still trying to tweak the settings on getting the image to display correctly, though, and any feedback is welcomed.

    stvwlf

    (@stvwlf)

    Hi

    you are missing “repeat-y” on the background image. The default is repeat vertical and horizontal unless you specify otherwise. If you only want the image once horizontally, add repeat-y which will only repeat vertically
    background: url(.....) repeat-y % %;

    I got the image to display in the center horizontally by setting the first % to 40%

    The problem you are having is the image is under 400 pixels wide and the content area is wider than that. The background of the image is a different color than the background of the post, so there will be a stripe of a different color on either side of the image in the center.

    You need to do one of these:
    1) create the image as wide as the post content area
    2) change the background color in the post area to the image background color
    3) create the image with a transparent background color, and save it as a PNG, which will let the post area background color shine through the parts of the image that are not the tree
    4) create the image with a background color the same color as the post background

    Thread Starter marcmoss

    (@marcmoss)

    stvwlf, you’ve been most helpful. Thank you for your time.

    Turns out WP was resizing the image when I upped it. I never looked @ image properties once I upped it to WP, but after reading your post, I figured, “why not?” and had a look.

    The 538px image that I uploaded had been resized by \wp to 248 (I think) or something like that.

    I uploaded the image to a different hosting site and used *that* one, and, voila, things display as I’d intended.

    For reference, the code that worked with the correctly sized image (538px) is below.

    Thanks again, stvwvlf.

    .maincol{
    
    	float: left;
    
    	width: 538px;
    
    	text-align: left;
    
    	vertical-align: top;
    
    background-color: #f6fbe5;
    
    background-image: url(http://farm4.static.flickr.com/3315/3544403847_7e7e3f0537_o.jpg);
    
    background-repeat: y;
    
    text-align:left;
    
    background-attachment: fixed;
    
    background-position: 40% 0%;
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Fixed background – image splits, seems to repeat’ is closed to new replies.