Help With CSS Backgrounds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rcmatt4321
    New Member
    • May 2007
    • 25

    Help With CSS Backgrounds

    First I have to tell you guys how much of a help you are to a kid my age. People literally gave me the code to solve my problem last time.

    Here is my problem.

    I am trying to get into the habit of using CSS with HTML (soon to be XHTML) and it is going pretty well. I am creating the shadow effect with a page so it looks like the content is floating on a plate, you have probably seen this all over the web. So I have a 800 pixel wide by 10 pixel tall image that is white with a gradient/shadow on both edges and a green bar to make a secondary content area on the right of the page. Here is the image.
    Here

    There is another image that should make a white bar across the top of the page that will eventualy hold a title. That image is here
    (Please Ignore the text!)

    Actually Here Is My Problem

    The First image is repeating itself down the page nicely. But the second image does not display at the top correctly, well sorta. Let me explain. Here is my Css code.
    Code:
    body {
    	background-image: url(../cssTesting/Images/wrapperGIF.gif);
    	background-repeat: repeat-y;
    	background-position: center center;
    	text-align: center;
    }
    #titleLayer	{
    	background-image: url(Images/wrapperTitleGIF.gif);
    	background-repeat: no-repeat;
    	background-position: center top;
    	background-attachment: fixed;
    	height: 70px;
    	width: 800px;
    	float: none;
    }
    Body Displays the shadowed image wrapperGIF.gif down the whole page and the class title layer is suposed to make the title image appear corectly. It does not. Click here to see what I mean. It does not display corectly in IE, Firefox, Netscape or Opera (Don't know about safari, wish I did though (:) Want a Mac!))

    Here is my HTML
    [HTML]<html>
    <link rel = "stylesheet " type = "text/css" href = "test.css">
    <div class="titleLay er" id="titleLayer" ></div>
    <body>
    </body>
    </html>[/HTML]

    The title kinda stops. But here is the wierd thing, when I put a space in between the 800 and px in my CSS it displays corectly. In IE, and Firefox but still not Opera or Netscape, but it probably renders in Safari IDK? I am just puzzeled why the space would do that. Here is another thing, when I put a space after the 70 it makes the layer really small, height wise?


    Also if it helps any the images are
    wrapperGIF (800, 10)
    wrapperTitleGIF (800, 70)

    Thanks,
    Matt
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    First I have to tell you guys how much of a help you are to a kid my age.
    You write more coherently than half the people that post on technical forums.

    I am trying to get into the habit of using CSS with HTML (soon to be XHTML)
    I would not concern myself with XHTML. IE doesn't recognize it and chances are you aren't serving it as such.

    I'm doing a major upgrade to my dev computer, coming up on 24 hours of updates, so don't know when I'll be able to look at this.

    Comment

    • rcmatt4321
      New Member
      • May 2007
      • 25

      #3
      Originally posted by drhowarddrfine
      You write more coherently than half the people that post on technical forums.
      Thanks!, I don't think so though. There are some pretty smart people here.

      See Ya,
      Matt

      Comment

      • rcmatt4321
        New Member
        • May 2007
        • 25

        #4
        Hey this is just a simple update. I have duplicated the css and html files 2 times and put them on the server for 2 reasons. One is that one has the space and another has no space inbetween the 800 and px. The other is so I can edit the original to see if I can find the awnser myself.

        Click here for the one with the spaces
        And here for the one without them.

        Thanks,
        Matt (The throughly stumped one)

        Comment

        • drhowarddrfine
          Recognized Expert Expert
          • Sep 2006
          • 7434

          #5
          No, you can't have a space between 800 and px.

          You need a doctype at the head of your page to keep browsers on the same set of rules. See the article at the top in the html/css section about doctypes. Also, read the part about validating.

          I totally botched my dev computer and need to reinstall everything.

          Comment

          • rcmatt4321
            New Member
            • May 2007
            • 25

            #6
            I added a Doctype, unfortunately it did nothing. I then validated it and it gave me a few errors. Please go valididate it with the W3C so I don't clutter copy and pasting it here. I only get a couple of errors. Some I don't understand why it is complaining about a head tag. My CSS is fine I even validated it. It is still having this wierd quirck where the img will go away after so many pixels, with or without the body background.

            Thanks,
            Matt

            Comment

            • drhowarddrfine
              Recognized Expert Expert
              • Sep 2006
              • 7434

              #7
              It complains about <head> because <title> is required.
              You are missing some "traditiona l" markup, such as <body>, <head>. Many may be surprised to know these are optional elements.

              You need a doctype no matter what. Browsers go into quirks mode and everything will be all screwed up.

              The error needs to be fixed in the css, too.

              Please explain about the space a little more. I see a problem but I don't know if we're talking about the same thing.

              Again, my dev computer is totally down and probably will be all day.

              Comment

              • rcmatt4321
                New Member
                • May 2007
                • 25

                #8
                Ok, I got it down to one error now. It tells me character data is not allowed in my link tag to associate the style sheet with the document. ???? Also I posted a screen shot of what I want it to look like. Click here to see it. The top is what the page looks like when there is no space in between the 800 and px, this is what I don't understand, when I put a space there I get the bottom. In The top screen shot the title img is definatley not 800 pixels wide because the background in 800 px wide??? Click on the links above for the ones with and without that space. Do you see what I am saying? I have tried but I still cannot get It to work.

                Thanks,
                Matt

                Comment

                • rcmatt4321
                  New Member
                  • May 2007
                  • 25

                  #9
                  Thanks for your guidence, I really only turn to here if I need to. I usualy try to figure it out myself. You should see how many books I have on programing almost 20 or 30. I don't know why just setting the width of the layer did not work. So I changed it to auto and I worked, in all the browsers (IE, FF, Netscape, Opera) could somebody please who is blessed enough to have a mac check it in safari for me. Here is my css code

                  Code:
                  body {
                  	background-image: url(../cssTesting/Images/wrapperGIF.gif);
                  	background-repeat: repeat-y;
                  	background-position: center center;
                  	text-align: center;
                  }
                  #titleLayer	{
                  	background-image: url(Images/expermentGIF.gif);
                  	background-repeat: no-repeat;
                  	background-position: top center;
                  	background-attachment: fixed;
                  	height: 70px;
                  	width: auto;
                  }
                  Thanks,
                  Matt

                  P.S. Could you please explain to me why setting the width of the layer did not work though...

                  Comment

                  • drhowarddrfine
                    Recognized Expert Expert
                    • Sep 2006
                    • 7434

                    #10
                    Is the page online? You said you are down to one error but I see four on one previous link and five on the other.

                    Comment

                    • rcmatt4321
                      New Member
                      • May 2007
                      • 25

                      #11
                      Yes they are click here to go to my css experiments section then click on test.html

                      Thanks,
                      Matt

                      Comment

                      • drhowarddrfine
                        Recognized Expert Expert
                        • Sep 2006
                        • 7434

                        #12
                        <link rel = "stylesheet " href = "test.css"/>

                        The closing /> is for Xhtml only. Remove the slash but leave the right arrow.

                        Here is more complete markup:
                        [HTML]
                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                        "http://www.w3.org/TR/html4/strict.dtd">
                        <html>
                        <head>
                        <title>Css Testing</title>
                        <link rel = "stylesheet " href = "test.css">
                        </head>
                        <body>

                        <div id="RsideBar">H ello</div>
                        <div id = "titleLayer "></div>

                        </body>
                        </html>[/HTML]

                        Comment

                        • rcmatt4321
                          New Member
                          • May 2007
                          • 25

                          #13
                          Thanks! I have another question now, sorry... I want to get a layer lined up with that green bar. How would I go about doing this, I cannot use absolute or relitave positioning because depending on the size of the browser window it would show up in different places.

                          Thanks,
                          Matt

                          Comment

                          • drhowarddrfine
                            Recognized Expert Expert
                            • Sep 2006
                            • 7434

                            #14
                            In your css, position what?
                            [code=css]

                            #titleLayer {
                            background-image: url(Images/expermentGIF.gi f);
                            background-repeat: no-repeat;
                            background-position: top center;
                            background-attachment: fixed;
                            height: 70px;
                            width: auto;
                            position
                            top: 0px;
                            }
                            [/code]

                            Comment

                            • rcmatt4321
                              New Member
                              • May 2007
                              • 25

                              #15
                              I would like to position a layer over that green bar. The only problem is that it will be in a different place on different screens.

                              Thanks,
                              Matt

                              Comment

                              Working...