SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    634
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    could I set diff background imgs on diff pages w/jquery

    This is what I am looking at...
    I have several pages, each one should have a diff background image in the ccs body tag. e.g.
    Code:
    body{
    background:url('imgs/image.png');
    }
    is there a way to load them with jquery or even css or do I need to make a diff stylesheet per page (wich is what is looking like to me so far).
    Thank you.

  2. #2
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,232
    Mentioned
    52 Post(s)
    Tagged
    2 Thread(s)
    You can assign a different class or ID in the body tag for each page, then associate the respective background image with that class/ID.
    Assuming all of the pages call the same css file, that should work just fine.
    Code:
    #page1 {background:url(...);}
    #page2 {background:url(...);}
    #page3 {background:url(...);}
    
    and the HTML would be
    
    <body id="page1">
    
    etc.
    Hope this is helpful.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    634
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ronpat, what a good point.
    I had actually not even thought of assigning an id to the body (kinda like the html) usually w/the exception of adding a background to it I leave them alone.
    No reason why it shouldn't work will try it out.
    Thank you!
    D

  4. #4
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    634
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ronpat, a quick follow up.
    That was a dead on great suggestions. Worked great.
    Thx

  5. #5
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,232
    Mentioned
    52 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by pdxSherpa View Post
    Ronpat, a quick follow up.
    That was a dead on great suggestions. Worked great.
    Thx
    You're very welcome, Sherpa. Glad to contribute to the cause


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •