2017-09-22 3 views
2

border-collapse이 적용된 테이블이 있습니다. 테이블 내에 과 같은 일부 td 경계를 제거하고 싶습니다. 나는 다음 코드를 사용하여 작업을 수행했지만이 코드는 제거하지 않으려는 다른 테두리의 1 픽셀을 제거합니다. 제거 된 border-right가 실제로는 테이블의 위쪽 및 아래쪽 테두리에 1px solid white 추가가 어디에html로 특정 테두리를 제거하는 완벽한 방법

<table> 
    <tr> 
     <th></th> 
     <th></th> 
     <th></th> 
    </tr> 
    <tr> 
     <td></td> 
     <td class="no-border-right"></td> 
     <td></td> 
    </tr> 
</table> 

이 어떻게 다른 국경에 영향을주지 않고 제거 할 수 있습니다

.no-border-right { 
 
     border-right: solid 10px #FFF!important; 
 
    } 
 

 
    table { 
 
     border-collapse: collapse; 
 
     font-size: 16px; 
 
     padding: 6px; 
 
    } 
 
    table td { 
 
     border: 10px solid gray;  
 
    } 
 
    table th { 
 
     border: 10px solid gray;  
 
    }
<table align="center"> 
 
    <tr> 
 
     <th>sl</th> 
 
     <th>name</th> 
 
     <th>score</th> 
 
     <th>rank</th> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td>John</td> 
 
     <td>2</td> 
 
     <td>1</td> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td class="no-border-right">James</td> 
 
     <td>1</td> 
 
     <td>2</td> 
 
    </tr> 
 
</table>

?

Output table

스 니펫에서 내 예상 된 결과는 다음과 같습니다 :

Expected output

+2

코드의 나머지 (HTML을 참조해야합니다/CSS) 또는 렌더링 된 페이지 사본. – Pytth

+0

@Pythth, 업데이트 된 질문을 참조하십시오. – theJohn

답변

2

table { 
 
    border-collapse: collapse; 
 
    padding: 6px; 
 
} 
 
table td, table th { 
 
    border: 1px solid gray; 
 
} 
 
table td.no-border-right { 
 
    border-right: none!important; 
 
} 
 
table td.no-border-right + td { 
 
    border-left: none!important; 
 
}
<table align="center"> 
 
    <tr> 
 
     <th>sl</th> 
 
     <th>name</th> 
 
     <th>score</th> 
 
     <th>rank</th> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td>John</td> 
 
     <td>2</td> 
 
     <td>1</td> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td class="no-border-right">James</td> 
 
     <td>1</td> 
 
     <td>2</td> 
 
    </tr> 
 
</table>

+0

흰색 1px 지점을 계속 볼 수 있습니다. – theJohn

+0

내가 편집 한 코드. 다시 시도하십시오. –

+0

그러면 테이블 안의 모든 테두리가 제거됩니다. 나는 특정한 국경을 원해. 업데이트 된 질문을보십시오. – theJohn

0

당신은 또한 당신을 위해 그것을해야 border-right: none;를 사용할 필요가 내가 갇히게되면 거기에 코드 조각을 남겼습니다.

.no-border-right { 
 
    border: 1px solid red; 
 
    display: inline-block; 
 
    /* from here up is not it's necessary just to help visually see it demonstration */ 
 
    
 
    border-right: none; /* Use this to remove right border */ 
 
}
<div class="no-border-right"> 
 
    <p>Hello Wolrd!</p> 
 
</div>

+0

제 발췌 문장으로 시도하십시오. 나는 또한 내 질문을 업데이 트 – theJohn

+0

이것은 작동하지 않습니다. 나는 HTML 테이블에서 일하고있다. – theJohn

+0

죄송합니다. – Kingcools

0

은과 같이 오른쪽 테두리 색상의 알파는 0 :

border-right { 10px solid rgba(0,0,0,0); } 

.no-border-right { 
 
     border-right: 10px solid rgba(0,0,0,0); 
 
    } 
 

 
    table { 
 
     border-collapse: collapse; 
 
     font-size: 16px; 
 
     padding: 6px; 
 
    } 
 
    table td { 
 
     border: 10px solid gray;  
 
    } 
 
    table th { 
 
     border: 10px solid gray;  
 
    }
<table align="center"> 
 
    <tr> 
 
     <th>sl</th> 
 
     <th>name</th> 
 
     <th>score</th> 
 
     <th>rank</th> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td>John</td> 
 
     <td>2</td> 
 
     <td>1</td> 
 
    </tr> 
 
    <tr> 
 
     <td>1</td> 
 
     <td class="no-border-right">James</td> 
 
     <td>1</td> 
 
     <td>2</td> 
 
    </tr> 
 
</table>

+0

해답을 보내 주셔서 감사합니다.하지만 스 니펫의 출력에서 ​​볼 수 있듯이 흰색 색은 제임스 – theJohn

+0

내 화면에 없습니다. 어떤 브라우저를 사용하고 있습니까? Im 최신 Chrome. – sn3ll

+0

나는 최신 firefox를 사용하고 있습니다. – theJohn

관련 문제