首页 > 解决方案 > 如何将日期选择器的日历图标放在 div 或 table 中

问题描述

我想将日期选择器的“calendar.png”图标放在 div 甚至表格中。目标是能够将其放置在我想要的任何位置。有了这个,我设法把它放在我想要的地方:

.ui-datepicker-trigger {
  position: absolute;
  left: 260px;
  top: 200px;
}

但我想把它放在 div 或 table 中。只有日历图标不是整个日历。

$(document).ready(function() {
  $('#demoDate').datepicker({
    showOn: "both",
    buttonImage: "calendar.png",
    buttonImageOnly: true
  });
});
#container * {
  vertical-align: middle
}

body .fondo {
  /*: 100px;*/
  margin-left: auto;
  margin-right: auto;
  position: absolute;
}

.widget {
  top: 50px;
  margin-left: auto;
  margin-right: auto;
  position: absolute;
}
<!DOCTYPE html>
<html>

<head>
  <title>jQuery UI Date Picker : buttonImage and buttonImageOnly </title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.3/themes/hot-sneaks/jquery-ui.css" />
  <script src="https://code.jquery.com/jquery-2.1.3.js"></script>
  <script src="https://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <style>

  </style>
</head>

<body>
  <div id="container" class="widget">
    <input id="demoDate" class="fondo" />
  </div>
</body>

</html>

标签: jquerycssdatepickerjquery-ui-datepicker

解决方案


推荐阅读