creating a color background

Discussion in 'CSS' started by rgordon83, Jun 10, 2007.

  1. #1
    rgordon83, Jun 10, 2007 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Specify a background color that targets the HTML tags you want using CSS:
    
    selector {
        background: white;
        color: black;
    }
    
    Code (markup):
    Where "selector" is the HTML tag, class or ID you are targeting (classes and IDs may have to be added though).
    To target a class, do this:
    
    .class { }
    
    Code (markup):
    Where .class is the value of the class attribute in your HTML you are targeting (like class="section").

    For IDs:
    
    #id { }
    
    Code (markup):
    Where #id is the value of the ID attribute you are targeting in your HTML (like id="content").
     
    Dan Schulz, Jun 10, 2007 IP
  3. CriminalOrigins

    CriminalOrigins Peon

    Messages:
    276
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Did you want to create a background color just on the links themselves?

    If so, you could simply use this code:

    
    .series_links a {
        background: #cccccc;
    }
    
    Code (markup):
    Replace #cccccc with whatever color code you'd like. If this isn't what you meant, let me know and I can post the appropriate code. :)
     
    CriminalOrigins, Jun 10, 2007 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just make sure that you provide a color value as well, even if it's just "inherit" - not to shut the CSS validator up, but in case someone forces a user stylesheet over yours. :)
     
    Dan Schulz, Jun 10, 2007 IP
  5. rgordon83

    rgordon83 Peon

    Messages:
    671
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #5

    so how would i then apply this style to the are i want? do ii need to add a div class?? also, is there a way to just get it to surround the links, but with maybe some extra padding, but not stretch all the way to the right edge of the page?


    thanks guys for your help so far...
     
    rgordon83, Jun 10, 2007 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Do you want the background on the list of links, or on the links themselves (and the answer is no, you don't need extra markup)?
     
    Dan Schulz, Jun 10, 2007 IP
  7. rgordon83

    rgordon83 Peon

    Messages:
    671
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i want it around that area. almost like my sidebar on my homepage, just not too the side...
     
    rgordon83, Jun 10, 2007 IP
  8. CriminalOrigins

    CriminalOrigins Peon

    Messages:
    276
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You could use something like this (add <div class="bg"> and </div> inside the series_links div):
    
    .series_links .bg {
        width: 400px;
        background: #cccccc;
        padding: 12px;
    }
    
    Code (markup):
    So your HTML code would look like this:
    
    <div class="series_links">
    <div class="bg">
    your links
    </div>
    </div>
    
    Code (markup):
    Hope that helps. If not, let me know :)
     
    CriminalOrigins, Jun 10, 2007 IP
    rgordon83 likes this.
  9. rgordon83

    rgordon83 Peon

    Messages:
    671
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #9

    thanks! that worked. check it out! but how do i decrease the empty space at the top? http://theguitarresource.com/store/
     
    rgordon83, Jun 10, 2007 IP
  10. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #10
    That's not the best way to do it, and in fact just adds bloat to the page.
     
    Dan Schulz, Jun 10, 2007 IP
  11. rgordon83

    rgordon83 Peon

    Messages:
    671
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #11
    any reccomendations?
     
    rgordon83, Jun 11, 2007 IP
  12. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #12
    "Never rush a miracle worker. All you'll get are bad miracles." -- Miracle Max (I think that was his name), "The Princess Bride"

    (that means I'm working on it - just bouncing around from computer to computer at the moment though)
     
    Dan Schulz, Jun 11, 2007 IP