douqiao8370 2018-08-16 06:05
浏览 98
已采纳

PHP - 用于datepicker的Bootstrap glyphicon(日历)包装到下一行

I have a small problem. When I try to show a datepicker in a form inserting the calendar glypycon , the glypycon wrap on the next line and is long as the date field. I want it instead on the rigth of the field and as small square. this is my code in the head section:

    <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.min.css">
    <script type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script>
<script type='text/javascript'>
$(function(){


$('.form-group.date').datepicker({

    calendarWeeks: true,
    todayHighlight: true,
    autoclose: true,
    format: "yyyy-mm-dd"
})
});

</script>

and this is the field in the form that give me error:

    <div class="row">
   <div class="col-sm-2 col-lg-2">
    <div class="form-group date">
   <label for="data">Data:</label>

      <input type="text" class="form-control"  id="datepicker" placeholder="Data" name="data" value="<?php echo($data); ?> ">
      <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                    </div>
</div></div>

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dongteng2534 2018-08-16 06:18
    关注

    You have to use input-group if you wish to bind another element on the INPUT..

    sample

    <div class="input-group">
          <input type="text" class="form-control" placeholder="Search for...">
          <span class="input-group-btn">
            <button class="btn btn-default" type="button">Go!</button>
          </span>
        </div>
    

    see bootstrap's documentation https://getbootstrap.com/docs/3.3/components/#input-groups

    If necessary, you can customize the positioning of the icon.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误