前一篇文章刚给大家分享了滑动组件(http://blog.youkuaiyun.com/sq_zhuyi/article/details/79103683),本篇文章就正好利用到这个滑动组件,在日历控件中实现选择时间的模块。同样,为了便于入题,我们先看效果图:
这是一个在租车项目中选择取车时间和还车时间的日历,其实同样的场景被用于很多旅游项目,用来选择出发、返程时间。
上代码,CSS模块:
.acal {
position: absolute;
left: 0;
right: 0;
top: 44px;
z-index: 100;
}
.acal .head {
position: fixed;
left: 0;
right: 0;
top: 44px;
z-index: 12;
height: 44px;
padding: 0 25px;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
background-color: #fff;
text-align: center;
}
.acal .head .dt {
line-height: 44px;
font-size: 18px;
}
.acal .head .day {
width: 3.5em;
line-height: 26px;
border: 1px solid #f00;
border-radius: 8px;
margin-top: 8px;
}
.acal .week {
position: fixed;
left: 0;
right: 0;
top: 88px;
z-index: 11;
line-height: 32px;
text-align: center;
background-color: #fff;
border-bottom: 1px solid #eee;
box-shadow: 0 2px 20px rgba(0,0,0,0.2);
}
.acal .week>i {
width: 14.28%;
}
.acal .calbody {
padding: 80px 0 200px 0;
background-color: #f9f9f9;
}
.acal .month {
position: relative;
}
.acal .month>h2 {
text-align: center;
line-height: 295px;
font-size: 80px;
color: #dedede;
font-weight: normal;
}
.acal .month .days {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.acal .month .days>i {
float: left;
width: 59px;
height: 39px;
margin: 10px 0;
text-align: center;
font-size: 20px;
position: relative;
}
.acal .month .days em {
width: 39px;
line-height: 39px;
border-radius: 50%;
position: absolute;
left: 10px;
top: 0;
z-index: 2;
}
.acal .month .days>i.disabled {
color: #999;
}
.acal .month .days>i.hover {
color: #fff;
}
.acal .month .days>i.hover>em {
background-color: #f00;
}
.acal .month .days>i.hover::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
z-index: 1;
background-color: #FFD2CF;
}
.acal .month .days>i.start::before {
left: 30px;
right: 0;
}
.acal .month .days>i.end::before {
left: 0;
right: 30px;
}
.acal .m