我正在尝试在 div 中使用 datePicker。我想在 datePicker 日历打开时扩展 div 的高度..
我有一个这样的div:
.dateBox{
width:160px;
height:auto;
border:1px solid blue;
}
问题是当你点击 datePicker 输入并打开日历时,.datebox 高度没有改变。我一直在玩,但我无法弄清楚......
我该如何解决?
直播:http://jsfiddle.net/fcrsznb1/2/
提前致谢!
.ui-datepicker {
width: 300px;
height: 300px;
margin: 5px auto 0;
font: 12pt Arial, sans-serif;
/*-webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
-moz-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);*/
}
.ui-datepicker table {
width: 100%;
}
.ui-datepicker-header {
background: #3399ff;
color: #ffffff;
font-family:'Times New Roman';
border-width: 1px 0 0 0;
border-style: solid;
border-color: #111;
}
.ui-datepicker-title {
text-align: center;
font-size: 15px;
}
.ui-datepicker-prev {
float: left;
cursor: pointer;
background-position: center -30px;
}
.ui-datepicker-next {
float: right;
cursor: pointer;
background-position: center 0px;
}
.ui-datepicker thead {
background-color: #f7f7f7;
/*border-bottom: 1px solid #bbb;*/
}
.ui-datepicker th {
background-color:#808080;
text-transform: uppercase;
font-size: 8pt;
color: #666666;
/*text-shadow: 1px 0px 0px #fff;*/
/*filter: dropshadow(color=#fff, offx=1, offy=0);*/
}
.ui-datepicker tbody td {
padding: 0;
/*border-right: 1px solid #808080;*/
}
.ui-datepicker tbody td:last-child {
border-right: 0px;
}
.ui-datepicker tbody tr {
border-bottom: 1px solid #bbb;
}
.ui-datepicker tbody tr:last-child {
border-bottom: 0px;
}
.ui-datepicker a {
text-decoration: none;
}
.ui-datepicker td span, .ui-datepicker td a {
display: inline-block;
/*font-weight: bold;*/
text-align: center;
width: 30px;
height: 30px;
line-height: 30px;
color: #ffffff;
/*text-shadow: 1px 1px 0px #fff;*/
/*filter: dropshadow(color=#fff, offx=1, offy=1);*/
}
.ui-datepicker-calendar .ui-state-default {
background: linear-gradient(#999999, #737373);
color:#ffffff;
height:40px;
width:40px;
}
.ui-datepicker-calendar .ui-state-hover {
background: #33adff;
color: #FFFFFF;
}
.ui-datepicker-calendar .ui-state-active {
background: #33adff;
-webkit-box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .1);
-moz-box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .1);
box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, .1);
color: #e0e0e0;
text-shadow: 0px 1px 0px #4d7a85;
border: 1px solid #55838f;
position: relative;
margin: -1px;
}
.ui-datepicker-unselectable .ui-state-default {
background: #D6E4BE;
color: #000;
}
如果您想为日期框设置动画,您可以尝试使用:
$( "#datepicker1" ).datepicker({ showAnim: "fold" })
您可以使用此处列出的任何效果:http://api.jqueryui.com/category/effects/
这里有一个 jsfiddle 向您展示它的工作原理:http://jsfiddle.net/fcrsznb1/3/
如果您想做其他事情,您可能需要查看文档。
http://api.jqueryui.com/datepicker/ 看看是否有任何选项可以满足您的需求。
右键单击
datepicker
框。在 Chrome 中选择“检查”(Ctrl+Shift+I) 或在 Firefox 中选择“检查元素”(Q)。找到您要更改的 CSS 样式。
例子:
.ui-datepicker {
font-size: 5%;
}
.ui-widget-header {
background: #77CC6D;
}
.ui-widget-content .ui-state-default:hover{
background: #77CC6D;
border-radius: 2px;
}
要更改日期格式,请更改脚本:
$(document).ready(function() {
$("#datepicker").datepicker({ dateFormat: 'D, d-M-yy' });
});
D > 日
d > 日期
M > 短月(一月)
MM > 长月(一月)
m > 月数 (1)
mm > 月份双数 (01)
y > 年 (17)
yy > 年份 (2017)
您需要自己引用日期选择器类并更改它们的样式。
而不是使用这个
.dateBox{
width:160px;
height:auto;
border:1px solid blue;
}
将名称更改为此,看看那是不是您要找的
.ui-widget-content{
width:160px;
height:auto;
border:1px solid blue;
}
日期选择器的自定义 CSS:
/* datepicker css */
.ui-datepicker {
background: #000000; /* Old browsers */
background: #000000 -moz-linear-gradient(top, #fcfcfc 0%, #fff 100%); /* FF3.6+ */
background: #000000 -webkit-gradient(linear, left top, left bottom, color-
stop(0%,#000000)), color-stop(100%,#34495e); /* Chrome,Safari4+ */
background: #000000 -webkit-linear-gradient(top,#000000 0%, #34495e 100%); /*
Chrome10+,Safari5.1+ */
background: #000000 -o-linear-gradient(top,#000000 0%, #34495e 100%); /* Opera11.10+
*/
background: #000000 -ms-linear-gradient(top,#000000 0%, #34495e 100%); /* IE10+ */
background: #000000 linear-gradient(top,#000000 0%, #34495e 100%); /* W3C */
font-size:11px;
padding:10px;
border:1px solid #5BFEC8;
width: 300px;
}
.ui-datepicker table td {
text-align:center;
}
.ui-datepicker a {
cursor:pointer;
text-decoration:none;
}
.ui-datepicker-prev {
}
.ui-datepicker-next {
float:right;
}
.ui-datepicker-title {
text-align: center;
font-weight:bold;
}
.ui-widget.ui-widget-content{
border: 2px solid #5BFEC8;
}
.ui-datepicker th {
padding: .7em .3em;
text-align: center;
font-weight: bold;
border: 0;
color: #5BFEC8;
}
.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default{
border: 1px solid #5bfec8;
background: #000000;
font-weight: normal;
color: #5bfec8;
}
a.ui-state-default:hover{
border: 1px solid white;
background: #5bfec8;
font-weight: bold;
color: black;
}
.ui-state-active, .ui-widget-content .ui-state-active,
.ui-widget-header .ui-state-active {
border: 1px solid white;
background: #5bfec8;
font-weight: bold;
color: black;
}
.ui-state-highlight,
.ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {
border: 1px solid #dad55e;
background: #fffa90;
color: black;
}
.ui-widget-header {
border: 1px solid #5bfec8;
background: #080808;
color: #5bfec8;
font-weight: bold;
}
如果你想要多个不同风格的日期选择器,你可以使用
classes
选项。
将您的类名设置为特定日期选择器初始化的值:
$("#myInput").datepicker({
...
classes: "my-datepcker-class",
...
});
这将呈现一个带有主块的日期选择器,如下所示:
<div class="datepickers-container" id="datepickers-container">
<div class="datepicker my-datepcker-class ..." >
....
所以你可以覆盖这个日期选择器实例的任何内部样式
.my-datepcker-class .datepicker--content {
/* CSS styles here */
}