WebProgram/Tistory

[ Tstory ] 글쓴 날자를 캘린더 형식으로 만들기

Total Fix! 2018. 6. 19. 15:06

블로그 날짜를 캘린더 형식으로 표시하기 위한 소스입니다.


HTML 부분

Monday
24
March
2014


CSS 부분

.calendar_item {
	color: #8d8d7e;
	width: 92.3076923077px;
	height: 120px;
	position: absolute;
	margin: 0 auto;
	left: 0;
	right: 0;
	top: 50%;
	margin-top: -60px;
	border-radius: 10px;
	text-align: center;
	text-transform: uppercase;
	box-shadow: 0px 3px 0 2px rgba(0, 0, 0, 0.05), 0 0 0 1px #8d8d7e, 0 0 0 2px #777;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.calendar_item > * {
	position: relative;
	z-index: 10;
}
.calendar_item::before {
	content: '';
	display: block;
	position: absolute;
	background-image: linear-gradient(#f7f7ea, #cfcfc4);
	box-shadow: inset 0 -1px 0 #bbb, inset 0 3px 0 fbfbed;
	top: 0;
	left: 0;
	right: 0;
	height: 60px;
	border-radius: 10px 10px 0 0;
}
.calendar_item::after {
	content: '';
	display: block;
	position: absolute;
	background-image: linear-gradient(#f7f7ea, #cfcfc4);
	box-shadow: inset 0 -2px 0 #f9f9ec, inset 0 -3px 0 #fbfbed;
	bottom: 0;
	left: 0;
	right: 0;
	height: 60px;
	border-radius: 0 0 10px 10px;
}
.calendar_item > .weekday {
	font-size: 14px;
	margin-top: 10px;
	font-weight: 300;
}
.calendar_item > .day {
	font-size: 64px;
	margin-top: 0px;
	text-indent: -1px;
	font-weight: 600;
	font-family: impact;
	position: relative;
	opacity: 0.5;
	color: #68683d;
}
.calendar_item > .day::before {
	content: '';
	display: block;
	position: absolute;
	background-image: linear-gradient(#999, #555);
	top: 50%;
	margin-top: -1px;
	left: 2px;
	height: 10px;
	width: 3px;
	border-radius: 4px;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.calendar_item > .day::after {
	content: '';
	display: block;
	position: absolute;
	background-image: linear-gradient(#999, #555);
	top: 50%;
	margin-top: -1px;
	right: 2px;
	height: 10px;
	width: 3px;
	border-radius: 4px;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.calendar_item > .month {
	font-size: 11px;
	margin-top: -2px;
	font-weight: 300;
}
.calendar_item > .year {
	font-size: 14px;
	font-weight: 600;
}


글꼴에 따라서 글자 크기를 조절해야 할 수도 있습니다.


Javascript 부분

$month = new Array();
$month = ["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"];
$day = new Array();
$day = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'];
 
//연도 두자리 표시
$(".calendar_item > .year").html($date.getFullYear());
//월 뒤에 한칸 띄어쓰기
$(".calendar_item > .month").html($month[$date.getMonth()]);
$(".calendar_item > .day").html($date.getDate());
//요일 설정
$(".calendar_item > .weekday").html($day[$date.getDay()]);


월과 요일은 영문으로 표시해도 보기 좋음


결과 모양 (이미지)


보관용으로 작성합니다.