Блондинка,
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>calendar-rotate</title>
<style type="text/css">
.month {
--wh: 350px; /* менять размер тут px, em, и т.д.*/
border: 1px solid #000000;
width: var(--wh);
height: calc(var(--wh)/7 * var(--col));
border-spacing: 2px;
margin: 4px;
}
.month td {
border: 1px solid #000000;
text-align: center;
line-height: calc(var(--wh)/7 - 8px);
}
.month.vert {
width: calc(var(--wh)/7 * var(--col));
}
.month.vert tbody {
display: grid;
grid-gap: 2px;
grid-template-columns: repeat(var(--col), 1fr);
}
.month.vert tbody tr {
height: calc(var(--wh) - 4px);
display: grid;
grid-gap: 1px;
grid-template-columns: repeat(1, 1fr);
}
.day {
background-color: hsl(210, 100%, 90%);
color: hsl(210, 100%, 50%);
}
.day:nth-child(7n + 6),
.day:nth-child(7n + 7) {
background-color: hsl(348, 100%, 90%);
color: hsl(348, 100%, 50%);
}
</style>
</head>
<body>
<div id="calendar_rotate">
<div id="navigation_panel">
<button id="month_minus">◀</button>
<span id="background_month"><select id="month_select"></select></span>
<button id="month_plus">▶</button>
<button id="year_minus">◀</button>
<input id="year_input" type="number" size="4" value="" />
<button id="year_plus">▶</button>
<button id="month_rotate">➙</button>
</div>
<table class="month vert"></table>
<script>
var calendar = {
update: function(year, month) {
this.days.length = 7;
var stepDay = new Date(year, month, 1);
stepDay.setDate(stepDay.getDate() + 0 - ((stepDay.getDay() + 6) % 7));
var lastDay = new Date(year, month + 1, 0);
lastDay.setDate(lastDay.getDate() + 6 - ((lastDay.getDay() + 6) % 7));
while (stepDay <= lastDay) {
this.days.push(stepDay.getDate());
stepDay.setHours(24);
}
},
render: function() {
var html = '';
for (var i = 0, j = 0; i < this.days.length; j = ++i % 7) {
if (j == 0) html += '<tr class="week">';
html += '<td class="day">' + this.days[i] + '</td>';
if (j == 6) html += '</tr>';
}
this.element.innerHTML = html;
this.element.style.setProperty("--col", this.days.length / 7)
},
toggle: function() {
this.element.classList.toggle('vert');
},
};
var today = new Date(),
thisYear = today.getFullYear(),
thisMonth = today.getMonth();
calendar.days = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
selector = document.getElementById('month_select');
month_list = ['Январь', 'Февраль', 'Март', 'Апрель', ' Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
for (let i = 0; i < month_list.length; i++) {
selector.options[i] = new Option(month_list[i], i);
}
selector.selectedIndex = thisMonth;
selector.addEventListener('', load);
document.getElementById('year_input').addEventListener('input', load);
calendar.element = document.querySelector('.month');
document.getElementById('month_rotate').addEventListener('click', function() {
calendar.toggle();
});
function load() {
let year = document.getElementById('year_input').value;
let month = selector.selectedIndex;
calendar.update(year, month);
calendar.render();
}
document.addEventListener("DOMContentLoaded", () => {
document.getElementById('year_input').value = thisYear;
load();
});
</script>
</div>
</body>
</html>