td单元格中的输入组问题

时间:2018-04-10 02:28:25

标签: html twitter-bootstrap

我想在td单元格下放一个bootstrap datepicker,我使用下面的html代码:

<td>
  <div class="input-group date">
    <input type="text" class="form-control datePicker">
    <span class="input-group-addon">
       <span class="glyphicon glyphicon-calendar"></span>
    </span>
  </div>
</td>

结果如下: Screenshot

2 个答案:

答案 0 :(得分:1)

尝试以下代码段。按照以下标记结构。并且您需要添加form-group类以使其看起来相似。

&#13;
&#13;
$(function() {
  $('#datetimepicker1').datetimepicker();
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href="./css/prettify-1.0.css" rel="stylesheet">
<link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet">

<table>
  <tr>

    <td>
      Sample cell
    </td>
    <td>
      <div class="form-group">
        <input type='text' class="form-control" />
      </div>
    </td>
    <td>
      <div class="form-group">
        <div class='input-group date' id='datetimepicker1'>
          <input type='text' class="form-control" />
          <span class="input-group-addon">
      <span class="glyphicon glyphicon-calendar"></span>
          </span>
        </div>
      </div>
    </td>
  </tr>

</table>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
<script src="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
&#13;
&#13;
&#13;

答案 1 :(得分:-1)

&#13;
&#13;
    		<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
    		<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
    			<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
    			<script src="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
    <script>
     $(function () {
                $('#datetimepicker1').datetimepicker();
            });
    </script>
&#13;
  <p>You can try this</p>
    <link rel="stylesheet" type="text/css" media="screen" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
            <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
            <link href="./css/prettify-1.0.css" rel="stylesheet">
    <link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
    <div class="container">
        <div class="row">
            <div class='col-sm-6'>
                <div class="form-group">
                    <div class='input-group date' id='datetimepicker1'>
                        <input type='text' class="form-control" />
                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-calendar"></span>
                        </span>
                    </div>
                </div>
            </div>
           
        </div>
    </div>
&#13;
&#13;
&#13;

Demo