我希望我的日历glyphicon正好在输入的下一个(右边),但它在输入下方向下跳跃。
我该如何解决
代码
<div class="col-sm-9">
<div class="input-group">
<input type="text" class="form-control" [(ngModel)]="TickleDate" name="TickleDate" id="TickleDate" [minDate]="minDate" [maxDate]="maxDate"
#xdp="bsDatepicker" bsDatepicker [(bsValue)]="tickleValue" [bsConfig]="dpConfig">
<a href="#"><span class="glyphicon glyphicon-calendar"></span></a>
</div>
</div>
答案 0 :(得分:1)
在锚标记中使用input-group-addon
类。
Stack Snippet
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="col-sm-9">
<div class="input-group">
<input type="text" class="form-control" [(ngModel)]="TickleDate" name="TickleDate" id="TickleDate" [minDate]="minDate" [maxDate]="maxDate" #xdp="bsDatepicker" bsDatepicker [(bsValue)]="tickleValue" [bsConfig]="dpConfig">
<a href="#" class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></a>
</div>
</div>
答案 1 :(得分:1)
<input type="text" class="form-control"...>
应该采用可用的全宽度(col-xs-9
)。有两种方法可以将日历图标放在与输入字段相同的行中:
input-group-addon
添加到图标元素。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<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.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="col-sm-9">
<div class="input-group">
<input type="text" class="form-control" [(ngModel)]="TickleDate" name="TickleDate" id="TickleDate" [minDate]="minDate" [maxDate]="maxDate"
#xdp="bsDatepicker" bsDatepicker [(bsValue)]="tickleValue" [bsConfig]="dpConfig">
<span class="input-group-addon"><a href="#"><i class="glyphicon glyphicon-calendar"></i></a></span>
</div>
</div>
&#13;
col
类来控制输入宽度不占整个宽度,为图标留出一些空间。