发布于2022-03-26 15:16 阅读(1015) 评论(0) 点赞(2) 收藏(5)
我正在努力实现这一目标
我的代码如下
HTML
<input
type="date"
>
CSS
input {
border: 1px solid gray;
border-radius: 4px;
}
试试这个代码
.html 文件
<div id="datepicker-container" class="datepicker-container">
<span class="outline-element-container"> <input id="datepicker-input" type="text" class="openemr-datepicker input-textbox outline-element incorrect" placeholder="Type Name" objtype="7" name="action_element" objindex="" aria-label="Select Date"> <span class="correct-incorrect-icon"> </span></span>
<div id="datepicker"></div>
</div>
<div class="datepicker-container openemr-calendar" id="datepicker-div" ></div>
css 文件
/* datepicker css */
.ui-datepicker {
text-align: center;
}
.ui-datepicker-trigger {
margin: 0 0 0 5px;
vertical-align: text-top;
}
.ui-datepicker {
font-family: Open Sans, Arial, sans-serif;
margin-top: 2px;
padding: 0 !important;
border-color: #c9f0f5 !important;
}
.ui-datepicker {
width: 256px;
}
.openemr-calendar .ui-datepicker {
width: 191px;
}
.ui-datepicker table {
width: 256px;
table-layout: fixed;
}
.openemr-calendar .ui-datepicker table {
width: 191px;
table-layout: fixed;
}
.ui-datepicker-header {
background-color: #3e9aba !important;
background-image: none !important;
border-radius: 0;
}
.openemr-calendar .ui-datepicker-header {
background-color: #e6f7f9 !important;
border-width: 1px;
border-color: #c9f0f5;
border-style: solid;
}
.ui-datepicker-title {
line-height: 35px !important;
margin: 0 10px !important;
}
.openemr-calendar .ui-datepicker-title {
line-height: 20px !important;
}
.ui-datepicker-prev span {
display: none !important;
}
.ui-datepicker-next {
text-align: center;
}
.ui-datepicker-next span {
display: none !important;
}
.ui-datepicker-prev {
background-color: transparent !important;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAMCAYAAACulacQAAAAUklEQVQYlXWPwQnAMAwDj9IBOlpH8CjdJLNksuujFIJjC/w6WUioFBcqJ7sGEAD5Y/hpqLRghRv4YQlUjqXI3Kql2MixraGbEhVcDXcFUR/1egEHNuTBpFW0NgAAAABJRU5ErkJggg==') !important;
height: 12px !important;
width: 7px !important;
margin: 14px 12px;
display: inline-block;
left: 0 !important;
top: 0 !important;
}
.openemr-calendar .ui-datepicker-prev {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAOCAYAAAD9lDaoAAAAuUlEQVQokXXRsUtCYRAA8J8pDQ1CVIgIgtBU2NDiZIuDS4uLf6WDS1O0tLREEE8icBNKS3lTs8/B78XHw3dwcHA/juOuqjzucYJVrQQMcYctvo4OgEFIeMK6iPphCjzjEWLUC3vACx7yRo5uMUIFr5gii1EL41AvMIkBVPGH04DrSLEsIvjEOZq4wi9+iijDR0ANXOMbmxjlcIY2LtANO6YxymGCDs5wg/ciYv+KBJeY4+2A+Y9j4Y47RtUkrNXeDxUAAAAASUVORK5CYII=') !important;
height: 14px !important;
width: 9px !important;
margin: 5px !important;
}
.ui-datepicker-next {
cursor: pointer;
}
.ui-datepicker-prev {
cursor: pointer;
}
.ui-datepicker-next {
background-color: transparent !important;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAMCAYAAABfnvydAAAAVUlEQVQYlXWQ0Q3AIAhEL07gKI7kKN2kI3Wk1w9to3KQEELucQEECOizhhTQGHFnwOdgobWx0GkZILfYBhXl0STVbPoBarbkL7ozN/F8VBBXh8uJgF5r2hrI4GHUkAAAAABJRU5ErkJggg==') !important;
height: 12px !important;
width: 8px !important;
margin: 14px 12px;
display: inline-block;
right: 0 !important;
top: 0 !important;
}
.openemr-calendar .ui-datepicker-next {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAOCAYAAAASVl2WAAAAtElEQVQYlXXQsUpCcRQH4I97EQyHa1pgIEE0hBGYL+BjNLRFjxXh4rM4F21BS4S4FAgqQioOngt/RM/6+zi/w4EanlA4MDkecYsO3vG/D8a4Rx03eMMqBQt8oodTXAdalwBm+IpNDVxG3aYEMMU3ujjDBT5SAH9R2cE58mwPFOgneJSCGp7RjLoXTEtQjbCFOV7xCxkqdp9sYxnhpFyb4QFXdh8c4Cc9Ko++OwzjFwfn5FiwBVeuI/K2UCkSAAAAAElFTkSuQmCC') !important;
height: 14px !important;
width: 8px !important;
margin: 5px;
}
.ui-datepicker-month {
border-radius: 2px;
background-color: #3985a0;
width: 110px !important;
height: 22px;
font-family: Open Sans !important;
color: #fff;
font-size: 14px !important;
font-weight: 600;
text-align: left;
border: none !important;
margin-right: 17px !important;
vertical-align: text-top;
}
.openemr-calendar .ui-datepicker-month {
font-family: Open Sans, Arial, sans-serif;
color: rgba(34, 34, 34, 0.87);
font-size: 12px !important;
font-weight: 700;
text-align: center;
transform: scaleX(1.0029)
}
.ui-datepicker-year {
border-radius: 2px;
background-color: #3985a0;
width: 61px !important;
height: 22px;
border: none !important;
font-family: Open Sans !important;
color: #fff;
font-size: 14px !important;
font-weight: 600;
text-align: left;
vertical-align: text-top;
}
.openemr-calendar .ui-datepicker-year {
font-family: Open Sans, Arial, sans-serif;
color: rgba(34, 34, 34, 0.87);
font-size: 12px !important;
font-weight: 700;
text-align: center;
transform: scaleX(1.0029)
}
.ui-datepicker-month option,
.ui-datepicker-year option {
color: #3985a0 !important;
background-color: #fff !important;
font-family: Open Sans !important;
font-size: 14px !important;
font-weight: 600;
}
.ui-datepicker-month option[selected],
.ui-datepicker-year option[selected] {
background-color: #e5edf0 !important;
}
.ui-datepicker .ui-state-hover {
/*background: none !important;*/
border: 0 !important;
}
.ui-datepicker td {
vertical-align: top;
}
.ui-datepicker .ui-state-default {
border-radius: 2px;
border-color: #edebeb !important;
/* background: white !important; */
width: 24px;
height: 24px;
padding: 0 !important;
line-height: 24px;
text-align: center !important;
font-family: Open Sans, Arial, sans-serif;
color: #707070;
font-size: 13px;
font-weight: 400 !important;
margin: 7px 0 0 4px;
}
.ui-datepicker .ui-state-default.ui-state-highlight{
border-color: #dcdcdc;
background-color: #cff3f8 !important;
color: #3e9aba !important;
}
.openemr-calendar .ui-state-default {
font-size: 10px;
margin: 0;
}
.ui-datepicker td {
width: 33px;
}
.openemr-calendar .ui-datepicker td {
width: 26px;
}
.openemr-calendar .ui-state-default {
width: 26px;
height: 20px;
line-height: 20px;
}
.ui-state-default.ui-state-hover {
border-color: #dcdcdc;
background-color: #cff3f8 !important;
}
.ui-datepicker .ui-state-active {
border-color: #dcdcdc;
background-color: #cff3f8 !important;
color: #3e9aba !important;
}
.ui-datepicker-calendar thead tr th {
font-family: Open Sans, Arial, sans-serif;
color: #549fa8;
font-size: 12px;
font-weight: 400;
padding: 0.45em 0.3em !important;
/* width: 15px !important; */
}
.openemr-calendar .ui-datepicker-calendar thead tr th {
font-size: 10px;
}
.ui-datepicker-close {
display: none;
}
.ui-datepicker thead {
background-color: #f5f5f5;
}
.openemr-calendar .ui-datepicker thead {
background: none;
}
.ui-state-default.ui-datepicker-current {
float: none !important;
font-family: Open Sans, Arial, sans-serif;
color: #fff;
font-size: 14px;
font-weight: 400;
text-align: left;
border-width: 0 !important;
border: none;
vertical-align: top;
margin: 0 !important;
background-color: transparent !important;
}
.ui-datepicker-buttonpane.ui-widget-content {
text-align: center;
background-color: #3e9aba;
margin: 0 !important;
height: 28px;
padding: 0 !important;
}
.openemr-calendar .ui-datepicker-year {
background-color: transparent;
}
.openemr-calendar .ui-datepicker-month {
background-color: transparent;
}
.openemr-calendar .ui-state-default {
border: 0 !important;
}
.openemr-calendar .ui-datepicker-month {
margin-right: 10px !important;
}
js文件
$( "#datepicker-input" ).datepicker({
// altField: "#datepicker-input",
// altFormat: "yy-mm-dd",
showButtonPanel: true,
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: "c-100:c+10",
dayNamesMin : [ "S", "M", "T", "W", "T", "F", "S" ],
// defaultDate: +1,
buttonImageOnly: true,
buttonImage: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAATCAYAAAB2pebxAAABGUlEQVQ4jc2UP06EQBjFfyCN3ZR2yxHwBGBCYUIhN1hqGrWj03KsiM3Y7p7AI8CeQI/ATbBgiE+gMlvsS8jM+97jy5s/mQCFszFQAQN1c2AJZzMgA3rqpgcYx5FQDAb4Ah6AFmdfNxp0QAp0OJvMUii2BDDUzS3w7s2KOcGd5+UsRDhbAo+AWfyU4GwnPAYG4XucTYOPt1PkG2SsYTbq2iT2X3ZFkVeeTChyA9wDN5uNi/x62TzaMD5t1DTdy7rsbPfnJNan0i24ejOcHUPOgLM0CSTuyY+pzAH2wFG46jugupw9mZczSORl/BZ4Fq56ArTzPYn5vUA6h/XNVX03DZe0J59Maxsk7iCeBPgWrroB4sA/LiX/R/8DOHhi5y8Apx4AAAAASUVORK5CYII=",
buttonText: "Pick Date",
showOn: "button",
});
// debugger;
$( "#datepicker-div" ).datepicker({
// altField: "#datepicker-input",
// altFormat: "yy-mm-dd",
// hideIfNoPrevNext = true,
dateFormat: "dd/mm/yy",
yearRange: "c-100:c+10",
dayNamesMin : [ "S", "M", "T", "W", "T", "F", "S" ],
// defaultDate: +1,
});
作者:黑洞官方问答小能手
链接:http://www.qianduanheidong.com/blog/article/322373/c073f0d9952eac3be4a7/
来源:前端黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 前端黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-3
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!