SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there a way to get an idea/class to have all the properties of a class/id?

    Hi,

    I'd like to know if the following can be done:

    Code:
    .some-class {
     (get all the properties of .other-class)
    }
    Regards,

    jj.

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,061
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Not directly, but you can do this:

    Code CSS:
    .someclass, .otherclass {
      // properties both classes need to have
    }
     
    .someclass {
      // properties for someclass only
    }
     
    .otherclass {
      // properties for otherclass only
    }

    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Non-Member
    Join Date
    Jun 2010
    Location
    47°27′35″N 26°18′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    .some-class {
     (get all the properties of .other-class)
    }
    it appears to me you are describing cascading

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if .other-class are children of .some-class then "inherit" in the css styles should work.

  5. #5
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,567
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    As others stated you can't have a class inherit CSS . Only a few properties inherit to children elements but most don't (which makes sense, if margins/paddings/backgrounds inherited to children, then that'd be a mess )

    Also note that the inherit value (as the above poster has stated) will work, HOWEVER IE7 and down don't support inherit except on a few minor properties (they won't help you with simple designing of a page)
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  6. #6
    Non-Member
    Join Date
    Jun 2010
    Location
    47°27′35″N 26°18′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he said it wrong, but aren't you forgetting the case when the classes are for the same element?

    h1 {many css rules here}
    h1.more {/*has the rules from h1 + */ additional css rules }
    h1.moreandmore {/*has the rules from h1, but none from h1.more + */ some other additional css rule}

    i believe it's called exactly inheritance


    h1.more {
    (get all the properties of h1)
    }

  7. #7
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,567
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by noonnope View Post
    he said it wrong, but aren't you forgetting the case when the classes are for the same element?

    h1 {many css rules here}
    h1.more {/*has the rules from h1 + */ additional css rules }
    h1.moreandmore {/*has the rules from h1, but none from h1.more + */ some other additional css rule}

    i believe it's called exactly inheritance
    As I'm sure you already knew, even as I worded my post, I was talking about this

    <div style="margin-left:100px;"><span>ljf</span></div>

    Had the span inherited the left margin then the span would be 200px over. I wasn't saying you can't inherit stuff via being more selective with your CSS rules, not at all.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  8. #8
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I want to do can't be done, then

    The mood in the CSS forum is always a pleasure


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
  •