SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot HardDriver's Avatar
    Join Date
    Feb 2004
    Location
    Kentucky, USA
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Shaving off those last few KB's...

    Is it possible to define multiple background's for a class/id without redefining all of the other attributes?

    To clarify, I have a DIV spanning across the top of my page, with my logo set as the background. I want to be able to change this logo by simply defining a different class or a unique ID - without having to define the height, width, and background color each time in the style sheet. Is this possible?

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you can use multiple class assignment to accomplish this. In one class you define the width, height, etc. and in the other whatever else you want.

    HTML Code:
    <style type="text/css">
    .classOne
    {
      height: 10%;
      width: 100%;
      /* other properties */
    }
    
    .classTwo
    {
      /* some more properties */
    }
    </style>
    <div class="classOne classTwo">...</div>
    Joe

    P.S. Now that I've though about it I'm not sure what you intend to do. Perhaps this may not be it but maybe it'll help.

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes.

    Most elements can have an ID and belong to multiple classes.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  4. #4
    SitePoint Zealot HardDriver's Avatar
    Join Date
    Feb 2004
    Location
    Kentucky, USA
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, this is perfect! Thanks so much for your help, guys!


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
  •