2012-04-02 6 views
1

테이블 헤더의 높이가 고정되어 있고 너비가 헤더 셀 내용을 기준으로 조정되어 있는지 확인해야합니다. (헤더 텍스트는 최대 두 줄로 표시됩니다.) 스타일을 사용하여 어떻게 할 수 있습니까? 또한 표 행의 너비가 머리글 행 너비와 동일해야합니다 (즉, 머리글 행에서 너비를 결정).헤더의 고정 높이와 너비 변경 (HTML 테이블)

참고 : 현재 "트랜잭션 부서 소유자 별칭 이름"이 나타납니다. 그것은 두 줄로 올 필요가 있습니다.

enter image description here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head><title> 


</title><link href="Styles/TestStyle.css" rel="stylesheet" type="text/css" /></head> 



<body> 


<div id = "divForTransactionGrid"> 

    <div> 

      <table cellspacing="0" rules="all" border="1" id="grdTransactions" style="border-collapse:collapse;"> 

          <thead> 

              <tr> 

                  <th scope="col">Transaction ID</th><th scope="col">Transaction Name</th><th scope="col">Transaction Owner</th><th scope="col">Transaction Department Owner Alias Name</th> 

              </tr> 

          </thead><tbody> 

              <tr> 

                  <td>1</td><td>TR1</td><td>Lijo</td><td>Lijo</td> 

              </tr><tr> 

                  <td>2</td><td>TR2</td><td>Lijo</td><td>This is a test value to test the result in real time scenario. Row width should be same as header width</td> 

              </tr> 

          </tbody> 

      </table> 

</div> 

</div> 





</body> 

</html> 

당신은 큰 문제가 파괴되어

#divForTransactionGrid 

{ 

width: 300px; 

height: 250px; 

overflow:scroll; 

} 
+0

몇 시간을 보내고 약간의 질문 공간을 고칠 수 있습니까? – Aristos

답변

2

CSS.
Transaction Department Owner Alias Name
그러나
Transaction&nbsp;Department&nbsp;Owner&nbsp;Alias&nbsp;Name
는 하나의 단어처럼 함께 머물 수있는 문장을 강제로, 새로운 라인에 각 공간 ","휴식을 할 수 있습니다.

당신이해야 할 일은 당신이 깰 수있는 하나의 규칙적인 공간을 남기고, & nbsp;을 사용하면 그것이 깨지기를 원하지 않고 2 줄 이하의 줄을 가질 수 있습니다. 정확히 2 줄의 경우 줄 바꿈 공간 ""대신 줄 바꿈 <br>을 사용하십시오. 행운을 빌어 요.