2013-02-14 1 views
1

나는 너비가 100 % 인 테이블을 가지고있다; enter image description hereHtml 표가 100 % 너비이지만 TD가 증가하고 있습니까?

I have 2 TDs.

그러나 나는 left 끝에 근처로 td 두 번째를 원한다. (직후에 ccccccc ...)

There is a solution 너비가 100 % 인 td를 1 개 더 사용합니다. 다른 TD없이 다른 솔루션 이 있는지

<table id="mytable"style="width:100%;background:red"><tr> 
    <td>TEXT1</td> 
    <td>TEXT2</td> 
    <td style="width:100%;background:blue">&nbsp;</td> 
    </tr></table> 

같은

뭔가, 나는 궁금 해서요?

답변

3

이 시도 : http://jsfiddle.net/Rrkky/144/ 은 당신이 요구하는지 정확히 무엇을합니까.

HTML

<table id="mytable"style="width:100%;background:red"> 
    <tr> 
    <td class="firstcell">aaaa</td> 
    <td>TEXT2</td> 
    </tr> 
    <tr> 
    <td class="firstcell">bbbbbbb</td> 
    <td>TEXT2</td> 
    </tr> 
    <tr> 
    <td class="firstcell">ccccccccccccccc</td> 
    <td>TEXT2</td> 
    </tr> 
</table> 

CSS

#mytable td { 
    width:50px; 
    background:green 
} 

#mytable td.firstcell { 
    background:red; 
    width:1%; 
} 
+0

+1 좋은 솔루션 – HamZa

+0

왜 50 픽셀 폭? –

+0

그것은 jsFiddle 코드에서 오는 것입니다. 네가 필요하다고 생각 했어. 당신도 그것을 제거 할 수 있습니다 :) – Mike

2

어떨까요?

<table id="mytable"style="width:100%;background:red"> 
    <tr> 
     <td>aaa</td> 
     <td width="100%">Royi</td> 
    </tr> 
    <tr> 
     <td>bbbbbb</td> 
     <td width="100%">Royi</td> 
    </tr> 
    <tr> 
     <td>cccccccccccccccc</td> 
     <td width="100%">Royi</td> 
    </tr> 
</table> 
1

http://jsfiddle.net/rjsAG/

그냥 마지막 TD를 추가했지만 두 번째

,745에 대한 width:100%를 사용하지 않는
+0

@HamZa DzCyberDeV와 동일한 +1 솔루션 –

1

CSS

tr td:not(:first-of-type){ 
    width:100% 
} 

또는

tr td{ 
    width:100% 
} 
tr td:first-child{ 
    width:1% 
} 
+0

': 아니다 (:'** ** 크로스 브라우저 (현재) psuedo selector (또한 : first-of-type) –

+0

범위 검증 및 프로젝트 플랫폼 지원은 OP에 의해 정의되지 않았습니다. –

+0

당신은 절대적으로 옳습니다. 그러나 이것은 지원되는 브라우저에 대한 좋은 해결책입니다. +1 –

관련 문제