2013-05-23 5 views
2

에서) ((홀수)가 아닌 n 번째의 아이를 결합 : (홀수)와하지 (이 아니요 줄무늬) n 번째의 아이를나는 두 CSS 기능을 다음과 결합하는 문제가 CSS

HTML :

<table class="table-striped"> 
<tr> 
    <th>Header</th> 
</tr> 
<tr> 
    <td>Line 1</td> 
</tr> 
<tr class="not-striped"> 
    <td>Hidden line</td> 
</tr> 
<tr> 
    <td>Ligne 2</td> 
</tr> 
<tr> 
    <td>Line 3</td> 
</tr> 
<tr> 
    <td>Line 4</td> 
</tr> 
</table> 

CSS :

.table-striped tbody > tr:nth-child(odd):not(.not-striped) > td, 
.table-striped tbody > tr:nth-child(odd):not(.not-striped) > th { 
    background-color:#f00; 
} 

JSFIDDLE : http://jsfiddle.net/barbuslex/9Zck6/1/

JSFIDDLE2 : http://jsfiddle.net/barbuslex/4GLMZ/1/

나는 줄무늬가없는 줄이 다음 줄의 번갈아 가면서 색을 바꾸지 않고 꼭대기 줄과 같은 색으로 보이기를 바랍니다.

예 :

  • 헤더 : RED
  • 라인 1 : WHITE
  • 숨겨진 라인 : WHITE
  • 라인 2 : RED
  • 라인 3 : WHITE
  • 라인 4 : RED

내 테이블 i 역동적 그래서 가질 수

  • 헤더 : RED
  • 라인 1 : WHITE
  • 숨겨진 라인 : WHITE를
  • 라인 2 : RED
  • 숨겨진 라인 :
  • 라인 3 RED : WHITE
  • 행 4 : RED
  • 숨겨진 라인 : RED

도와 주시겠습니까?

감사

+0

. 다른 말로 설명하고 싶습니까? – Kasyx

+0

@Kasyx i 토픽 업데이트 – barbuslex

+0

스트라이프되지 않은 행은 항상 같은 위치에 있습니까? –

답변

1

당신이이 클래스는 &을 .stripped 사용이 아니요-제거 당신을 해달라고?

<table class="table-striped"> 
    <tr class="striped"> 
     <th>Header</th> 
    </tr> 
    <tr class="not-striped"> 
     <td>Line 1</td> 
    </tr> 
    <tr class="not-striped"> 
     <td>Hidden line</td> 
    </tr> 
    <tr class="striped"> 
     <td>Ligne 2</td> 
    </tr> 
    <tr class="not-striped"> 
     <td>Line 3</td> 
    </tr> 
    <tr class="striped"> 
     <td>Line 4</td> 
    </tr> 
</table> 

CSS :

.striped 
{ 
    background-color:#F00 
} 

.not-striped 
{ 
    background-color:#FFF 
} 

내 결과 : enter image description here

JSFiddle : 나는 당신이 달성하기 위해 트링하는 것을 이해 해달라고 enter link description here

+0

시도했지만 문제가 어떻게 해결되는지 보지 못 하셨나요? – barbuslex

+0

귀하의 업데이트가 제공되었지만 기능이 아닌 n 번째 자녀에게는 불가능하지만 불가능하지 않습니까? (왜냐하면 나는 트위터 부트 스트랩 CSS를 사용하기 때문에) 스트라이프 라인을 배경색으로 바꿀 것이다. – barbuslex

+0

나는 나의 대답을 편집했다 –