javascript - 如何更改 Bootstrap Datepicker 图标?

标签 javascript html css twitter-bootstrap bootstrap-datepicker

我想更改下一个上一个箭头。但是innerHTML不影响<th class="next">>></th> 。我能做什么?

$(".datepicker").datepicker();
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">

<input type="text" class="datepicker">

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>

最佳答案

这是另一个仅使用 CSS 的想法。

$(".datepicker").datepicker();
.table-condensed > thead > tr:nth-child(2) > .prev {
  font-size: 0;
  background: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Cline x1='19' y1='12' x2='5' y2='12'%3E%3C/line%3E%3Cpolyline points='12 19 5 12 12 5'%3E%3C/polyline%3E%3C/svg%3E") 50% 50% / contain no-repeat;
}

.table-condensed > thead > tr:nth-child(2) > .next {
  font-size: 0;
  background: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3Cpolyline points='12 5 19 12 12 19'%3E%3C/polyline%3E%3C/svg%3E") 50% 50% / contain no-repeat;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">

<input type="text" class="datepicker">

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>

使用 mask 更改图标的颜色:(您已经可以通过更改填充或描边颜色来更改 SVG 的颜色,但假设您使用的是 PNG 而不是 SVG)

$(".datepicker").datepicker();
.table-condensed > thead > tr:nth-child(2) > .prev {
  font-size: 0;
  --mask: url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Cline x1='19' y1='12' x2='5' y2='12'%3E%3C/line%3E%3Cpolyline points='12 19 5 12 12 5'%3E%3C/polyline%3E%3C/svg%3E") 50% 50% / contain no-repeat;
  -webkit-mask: var(--mask);
          mask: var(--mask);
   background: red;
}

.table-condensed > thead > tr:nth-child(2) > .next {
  font-size: 0;
  --mask: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' %3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3Cpolyline points='12 5 19 12 12 19'%3E%3C/polyline%3E%3C/svg%3E") 50% 50% / contain no-repeat;
  -webkit-mask: var(--mask);
          mask: var(--mask);
   background: blue;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">

<input type="text" class="datepicker">

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>

关于javascript - 如何更改 Bootstrap Datepicker 图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57088289/

相关文章:

javascript - 如何创建一个可以在代码中多次调用的等待函数

javascript - Firefox Addon 观察器 http-on-modify-request 无法正常工作

html - 如何使用 HTML5 Canvas 为轨道上的物体制作动画?

html - 中间的 CSS 按钮 "Center"

html - 即使我禁用了所有相关的 CSS,我网站上链接下的蓝线?

javascript - ruby on Rails 是否有像 ASP.NET MVC 一样的客户端验证

Javascript 主体加载一次

jquery - 滚动时导航变小

javascript - 在 html 中显示 php cookie

javascript - 隐藏时如何到达选择元素?