+ Reply to Thread
Results 1 to 8 of 8

Thread: how do I get a fixed background?

  1. #1
    alwaysdrawing is offline x10Hosting Member alwaysdrawing is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    7

    how do I get a fixed background?

    I'm not very familiar with programming, but I want to fix a background image to the center of a webpage. I'm believe I have the right code, but it's still not working. Does anyone know my problem?

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Ringtail</title>
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    background-image: url(ringtail_bg.jpg);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center top;
    }
    .style8 {font-family: Geneva, Arial, Helvetica, sans-serif; color: #A7080C; }
    -->
    </style>
    </head>
    <body>
    </body>
    </html>

  2. #2
    purpleflame's Avatar
    purpleflame is offline x10Hosting Member purpleflame is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    17

    Re: how do I get a fixed background?

    The code snippet I found to do this is very similar, but has quotes around the image file. Here is the one I found.
    Code:
    <style type="text/css">
    body {
       background-image:url("IMAGEFILE/NameofImage.jpg");
       background-repeat:repeat-y;
       background-position:top center;
       background-attachment:fixed
    }
    </style>
    
    Hope I Helped ^^

  3. #3
    mxl33t is offline x10Hosting Member mxl33t is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    15

    Re: how do I get a fixed background?

    Well, you can choose a wide background image and add
    scroll top to background like :

    background: url(bg.jpg) no-repeat scroll top ;

    This will set the image to top and there will be no scroll bars.

  4. #4
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: how do I get a fixed background?

    Just tried and tested the following - which works fine in both IE6 and FF.

    Code:
    body {
    	background: #fff url(../images/background.jpg) no-repeat fixed;
    }
    However, to centralise it, you will need a centralised container in addition to your <body> tag.

    Code:
    body{}
    
    #wrapper{
                    position: relative;
    	display: block;
    	background: #fff url(../images/background.jpg) no-repeat fixed;
    	width: 980px; /*or whatever width you want but the image above should be the same width*/
    	margin-left: auto;
    	margin-right: auto;
    }
    Body

    Code:
    <body>
    <div id="wrapper">
    
    <!-- whatever content-->
    
    </div>
    </body>
    Everything you want shown on the page would fit within this wrapper div.

    Although it isn't a problem yet, you may also want to upgrade your doc type to

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    Last edited by freecrm; 04-08-2009 at 07:02 AM.

  5. #5
    alwaysdrawing is offline x10Hosting Member alwaysdrawing is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    7

    Re: how do I get a fixed background?

    Thanks, I'll try this and see what happens.

    Oh, btw, how do you make items in a table NOT move around when you resize the window?

  6. #6
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: how do I get a fixed background?

    This is a very open-ended question and the anser depends entirely on your layout.

    If your wrapper is a fixed size for instance and the image is the same width, it won't move.

    If you have a smaller image embedded into a paragraph of text, this will move depending on the window size as the text wraps.

    This is why using divisions is so important. As with a table layout, you can specify the location of each image and how it interacts with neighboring divs.

  7. #7
    alwaysdrawing is offline x10Hosting Member alwaysdrawing is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    7

    Re: how do I get a fixed background?

    Thanks, freecrm. It's working the way I want it now.

  8. #8
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: how do I get a fixed background?

    My pleasure!

+ Reply to Thread

Similar Threads

  1. Relative paths or fixed paths?
    By tnl2k7 in forum Crossfire
    Replies: 9
    Last Post: 08-23-2008, 11:19 AM
  2. Fixed background image
    By stalkio in forum Programming Help
    Replies: 3
    Last Post: 07-26-2008, 10:41 AM
  3. Replies: 1
    Last Post: 05-31-2008, 09:23 PM
  4. can anyone convert a CSS into an IPB skin for me?
    By leafypiggy in forum Programming Help
    Replies: 0
    Last Post: 05-06-2008, 07:41 PM
  5. My web designe
    By dharmil in forum Graphics & Webdesign
    Replies: 7
    Last Post: 07-20-2006, 09:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers