2013-04-30 185 views
0

以下是兩個css。繼承css風格

我想要helpContent的所有樣式itemContent。我將如何讓helpContent繼承itemContent

.itemContent { 
    BORDER-RIGHT: #ababe3 1px solid; 
    BORDER-TOP: #ababe3 1px solid; 
    DISPLAY: block; 
    PADDING-LEFT: 3px; 
    PADDING-BOTTOM: 3px; 
    PADDING-TOP: 3px; 
    OVERFLOW: hidden; 
    BORDER-LEFT: #ababe3 1px solid; 
    WORD-WRAP: break-word; 
    POSITION: static; 
} 
.helpContent { 
    BACKGROUND: #eff5ff; 
} 
+5

類= 「itemContent helpContent」;與SASS你可以用@extend來做,但是用純CSS可以複製/粘貼... – philipp 2013-04-30 07:15:52

+0

@philipp在禿鷲出現之前把它作爲一個快速回答:p – lifetimes 2013-04-30 07:17:30

+0

不,這意味着div會有2個CSS 。我需要helpContent繼承itemContent。類似於.helpContent {背景:#eff5ff; itemContent; } – dumper 2013-04-30 07:18:03

回答

6

最簡單的方法將是

.itemcontent, .helpcontent { 
    border-right: #ababe3 1px solid; 
    border-top: #ababe3 1px solid; 
    display: block; 
    padding-left: 3px; 
    padding-bottom: 3px; 
    padding-top: 3px; 
    overflow: hidden; 
    border-left: #ababe3 1px solid; 
    word-wrap: break-word; 
    position: static; 
} 
.helpcontent { 
    background: #eff5ff; 
} 
+1

注意,忽略大寫 – 2013-04-30 07:21:49

+0

我已經從問題中複製了css代碼,只是將其更改爲繼承 – Robert 2013-04-30 07:23:27

+0

不用擔心:)我爲你做了它 – 2013-04-30 07:23:48

0

和最短的方式將是:

.itemcontent, .helpcontent { 
    border: 1px solid #ababe3; 
    border-bottom: none; 
    display: block; 
    padding: 3px 0 3px 3px; 
    overflow: hidden; 
    word-wrap: break-word; 
    position: static; 
} 
.helpcontent { 
    background: #eff5ff; 
}