Background image keeps being applied to ALL divs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • caseymai
    New Member
    • Apr 2012
    • 1

    Background image keeps being applied to ALL divs

    Hi,

    I have created a div with a background image, and i have now created new div's with no background image. but these new divs keep getting the first div's background image applied to them. i am not sure why. here is some of the css/style guide, the first div is the one i want with a background image, the second div i want to sit on top of the first div, with no background image.

    Code:
    div {
    id="background of box"
    width: 1000px;
    height: 1200px;
    background-image:url('images/LEFTBOX.jpg');
    background-repeat:no-repeat;
    }
    
    div {
    id="images"
    width: 200px;
    height: 700px;
    margin: 120px 200px 70px 35px;
    }
    i also have a problem where the background image is displaying half of it. i dont understand cos its 515px wide so it should definietly fit within the div. am i supposed to write the size of the div in the html section or on the stylesheet?

    help help help! please
    Last edited by Rabbit; Apr 18 '12, 03:12 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    The correct way to target CSS at an id is this:
    Code:
    #idText {}
    What you have doesn't target an id.

    Comment

    • hellodipak
      New Member
      • Jun 2010
      • 26

      #3
      div{......} = The css is being applied to all div tags in your document

      .divClass = The css is applied to the div that has this class in your document
      <div class="divClass ">Some text</div>

      Comment

      Working...