修改表格列

时间:2013-06-30 04:54:42

标签: angularjs

如何减少日期列的宽度(“MON”,“TUES”等)以匹配“MON”或“TUES等”所需的空间?换句话说,我想将day列的宽度设置为等于列标题的长度。

http://jsfiddle.net/BnLEh/

<div ng-app="MyModule">
<div ng-controller="Controller">
    <table border='1' width='200'>
        <tbody>
          <tr>
            <td ng-repeat='day in days' width='20%'>{{day}}</td>
          </tr>
          <tr ng-repeat='x in [1,2,3,4]'>
            <td>
                <input placeholder='Enter Charge #' size='10'>
            </td>
            <td ng-repeat='t in [1,2,3,4,5,6,7]' width='10%'>
                <input type="number" size='3'>
            </td>
          </tr>
      </tbody>
    </table>
  </div>
 </div>

var optModule = angular.module('MyModule', []);

    function Controller($scope) {   
        $scope.days = ["", "MON", "TUE", "WED", 
            "THU", "FRI", "SAT", "SUN"];        
    }

1 个答案:

答案 0 :(得分:1)

通过将宽度设置为100%

,将输入宽度设置为从其父级继承
<input style="width: 100%" type="number" size='3'>

http://jsfiddle.net/BnLEh/10/

textboxes in HTML table: How to auto-size?