gpt4 book ai didi

CSS:设置 jquery ui 日期选择器的样式?

转载 作者:行者123 更新时间:2023-12-02 20:34:57 25 4
gpt4 key购买 nike

我正在尝试设置 jquery UI 日期选择器的样式。

除了一个异常(exception),一切正常。

我需要让一切都居中,但我似乎无法实现这一点。

这是我到目前为止所拥有的:

    $('#calendar').datepicker({
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
});
.ui-datepicker,
.ui-datepicker table,
.ui-datepicker tr,
.ui-datepicker td,
.ui-datepicker th {
margin: 0;
padding: 0;
border: none;
border-spacing: 0;
}


.ui-datepicker {
display: none;
width: 100%;
padding: 35px;
cursor: default;

text-transform: uppercase;
font-family: Tahoma;
font-size: 24px;

background: #fff;

-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border:solid 1px #e91e62;
}


.ui-datepicker-header {
position: relative;
padding-bottom: 10px;
border-bottom: 1px solid #d6d6d6;
}

.ui-datepicker-title { text-align: center; }

.ui-datepicker-month {
position: relative;
padding-right: 15px;
color: #e91e62;
}

.ui-datepicker-year {
padding-left: 8px;
color: #e91e62;
}



.ui-datepicker-month:before {
display: block;
position: absolute;
top: 5px;
right: 0;
width: 5px;
height: 5px;
content: '';

background: #a5cd4e;
background: -moz-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a5cd4e), color-stop(100%,#6b8f1a));
background: -webkit-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -o-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -ms-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}


.ui-datepicker-prev,
.ui-datepicker-next {
position: absolute;
top: -2px;
padding: 5px;
cursor: pointer;
}

.ui-datepicker-prev {
left: 0;
padding-left: 0;
}

.ui-datepicker-next {
right: 0;
padding-right: 0;
}

.ui-datepicker-prev span,
.ui-datepicker-next span{
display: block;
width: 5px;
height: 10px;
text-indent: -9999px;

background-image: url(../img/arrows.png);
}

.ui-datepicker-prev span { background-position: 0px 0px; }

.ui-datepicker-next span { background-position: -5px 0px; }

.ui-datepicker-prev-hover span { background-position: 0px -10px; }

.ui-datepicker-next-hover span { background-position: -5px -10px; }


.ui-datepicker-calendar th {
padding-top: 15px;
padding-bottom: 10px;

text-align: center;
font-weight: normal;
color: #a8a8a8;
width:100%;
}

.ui-datepicker-calendar td {
padding: 0 7px;
text-align: center;
line-height: 26px;
}

.ui-datepicker-calendar .ui-state-default {
display: block;
width: 26px;
outline: none;

text-decoration: none;
color: #000;

border: 1px solid transparent;
}


.ui-datepicker-calendar .ui-state-active {
color: #e91e62;
border: 1px solid #e91e62;
}

.ui-datepicker-other-month .ui-state-default { color: #ccc; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<div id="calendar">
</div>

如果您查看上面的示例,您会看到一个不想要的间隙,并且日历的内容并未真正居中!

有人可以就这个问题提出建议吗?

如果需要的话,这里还有一个 fiddle :https://jsfiddle.net/u7cocxdy/2/

如有任何帮助,我们将不胜感激。

最佳答案

其中有一个 width:100% (.ui-datepicker-calendar th),我已将其删除。这样就消除了差距。然后我使用 margin: 0 auto 将表格居中。

$('#calendar').datepicker({
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
});
.ui-datepicker,
.ui-datepicker table,
.ui-datepicker tr,
.ui-datepicker td,
.ui-datepicker th {
margin: 0;
padding: 0;
border: none;
border-spacing: 0;
}

.ui-datepicker {
display: none;
width: 100%;
padding: 35px;
cursor: default;
text-transform: uppercase;
font-family: Tahoma;
font-size: 24px;
background: #fff;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #e91e62;
}

.ui-datepicker-header {
position: relative;
padding-bottom: 10px;
border-bottom: 1px solid #d6d6d6;
}

.ui-datepicker-title {
text-align: center;
}

.ui-datepicker-month {
position: relative;
padding-right: 15px;
color: #e91e62;
}

.ui-datepicker-year {
padding-left: 8px;
color: #e91e62;
}

.ui-datepicker-month:before {
display: block;
position: absolute;
top: 5px;
right: 0;
width: 5px;
height: 5px;
content: '';
background: #a5cd4e;
background: -moz-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #a5cd4e), color-stop(100%, #6b8f1a));
background: -webkit-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -o-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -ms-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}

.ui-datepicker-prev,
.ui-datepicker-next {
position: absolute;
top: -2px;
padding: 5px;
cursor: pointer;
}

.ui-datepicker-prev {
left: 0;
padding-left: 0;
}

.ui-datepicker-next {
right: 0;
padding-right: 0;
}

.ui-datepicker-prev span,
.ui-datepicker-next span {
display: block;
width: 5px;
height: 10px;
text-indent: -9999px;
background-image: url(../img/arrows.png);
}

.ui-datepicker-prev span {
background-position: 0px 0px;
}

.ui-datepicker-next span {
background-position: -5px 0px;
}

.ui-datepicker-prev-hover span {
background-position: 0px -10px;
}

.ui-datepicker-next-hover span {
background-position: -5px -10px;
}

.ui-datepicker-calendar th {
padding-top: 15px;
padding-bottom: 10px;
text-align: center;
font-weight: normal;
color: #a8a8a8;
}

.ui-datepicker-calendar td {
padding: 0 7px;
text-align: center;
line-height: 26px;
}

.ui-datepicker-calendar .ui-state-default {
display: block;
width: 26px;
outline: none;
text-decoration: none;
color: #000;
border: 1px solid transparent;
}

.ui-datepicker-calendar .ui-state-active {
color: #e91e62;
border: 1px solid #e91e62;
}

.ui-datepicker-other-month .ui-state-default {
color: #ccc;
}

.ui-datepicker table {
margin: 0 auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<div id="calendar">
</div>

关于CSS:设置 jquery ui 日期选择器的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47775112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com