

A5
以下ソース。HTML、CSS、JavaScript
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <!-- <meta year="2015"> --> <meta month="9"> <link rel="stylesheet" href="html_calendar.css"> </head><body><script src="html_calendar.js"></script></body></html>
var Calendar = function () { var elems = document.getElementsByTagName('meta'), d = new Date; this.year = d.getFullYear(); this.month = d.getMonth() + 1; for (var i = 0; i < elems.length; i++) { var ele = elems[i], y = ele.getAttribute('year'), m = ele.getAttribute('month'); if (y) this.year = parseInt(y); if (m) this.month = parseInt(m); } }; Calendar.prototype.prepareContainer = function () { var id = 'calendar', d = document.getElementById(id); if (d) return; var d = document.createElement('div'); d.id = id; document.body.appendChild(d); }; Calendar.prototype.displayYearMonth = function () { var d = document.createElement('div'); d.textContent = this.year + '/' + this.month; d.className = 'year month'; document.getElementById('calendar').appendChild(d); }; Calendar.prototype.displayDays = function () { var f = document.createDocumentFragment(), dow = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; var nextMonth = this.month % 12 + 1, nextMonthPre = nextMonth < 10 ? '0' : '', nextYear = this.year + (this.month === 12 ? 1 : 0), nextMonth1Day = new Date(nextYear + '-' + nextMonthPre + nextMonth + '-01'), tmpTime = nextMonth1Day.getTime() - 24 * 60 * 60 * 1000, tmpDate = new Date; tmpDate.setTime(tmpTime); for (var i = 1; i <= tmpDate.getDate(); i++) { var n = document.createElement('div'), m = (this.month < 10 ? '0' : ''), day = (i < 10 ? '0' : '') + i; tmp = new Date(this.year + '-' + m + this.month + '-' + day), yb = dow[tmp.getDay()]; n.textContent = i + ' ' + yb; n.className = 'days ' + yb; f.appendChild(n); } document.getElementById('calendar').appendChild(f); }; var c = new Calendar(); c.prepareContainer(); c.displayYearMonth(); c.displayDays();
body { background: whitesmoke; margin: 0; padding: 0; } #calendar { background: white; font-size: 11pt; font-family: Cambria; line-height: 1.2; padding: 1.25em 1em 0 2em; overflow: hidden; height: calc(209.9125mm - 1.25em); width: calc(148.5mm - 1em - 2em) ; /* A5 */ } .year.month { font-size: 1.5em; margin-bottom: 1em; } .days { border-top: solid black 1px; padding-left: 0.25em; } .days.Sun { margin-bottom: 2em; border-bottom: solid black 1px; } .days:last-child { border-bottom: solid black 1px; } @media print { body { background: white; } }
JavaScript
仕上りサイズは、CSS
↓


↓


明日、複数月版を作ったら今日のは不要になりますが、とりあえず作業経過の記録まで。