Блондинка,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8" />
<style type="text/css">
#wrapper button:after {
content: 'prev';
}
#wrapper button:nth-of-type(2):after {
content: 'next';
}
#wrapper button:nth-of-type(3){
order: 1;
}
#wrapper button:nth-of-type(2){
order: 2;
}
#wrapper button:nth-of-type(3):after {
content: 'сегодня';
}
#wrapper input {
width: 50px;
height: 18px;
margin-top: -3px;
text-align: center;
}
#wrapper {
width: 320px;
padding: 5px;
margin: 5px;
border: 1px solid #a9a9a9;
border-radius: 6px/4px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
#wrapper table {
flex: 1 0 100%;
border-collapse: separate;
width: 100%;
padding: 1px;
}
table,
th,
td {
border: 1px solid #a9a9a9;
border-radius: 6px/4px;
margin: 1px;
}
th,
td {
text-align: center;
}
.currentMonthWeek {
background-color: #def1ff;
color: #0091ff;
}
.currentMonthWeek:nth-child(n + 6) {
background-color: #ffc3d7;
color: #dc143c;
}
td.currentDay {
background-color: #c2d6ff;
border: 1px solid #00f;
font-weight: bold;
color: #fff;
text-shadow: 1px 1px #00f, -1px 1px #00f, 1px -1px #00f, -1px -1px #00f,
1px 0 #00f, 0 1px #00f, -1px 0 #00f, 0 -1px #00f;
}
td.currentDay:nth-child(n + 6) {
background-color: #ffc3d7;
border: 1px solid #ff69b4;
text-shadow: 1px 1px #ff0000, -1px 1px #ff0000, 1px -1px #ff0000, -1px -1px #ff0000, 1px 0px #ff0000, 0px 1px #ff0000, -1px 0px #ff0000, 0px -1px #ff0000;
}
#wrapper th {
background-color: #c2d6ff;
color: #0069ff;
}
#wrapper th:nth-child(n + 6) {
background-color: #ffb4d2;
color: #b92346;
}
#wrapper th.currentDay {
border: 1px solid #285fcd;
background-color: #6b9cff;
color: #e6f5ff;
}
#wrapper th:nth-child(n + 6).currentDay {
background-color: #ff389c;
color: #ffed85;
}
#wrapper button {
flex 0;
border: 1px solid #a9a9a9;
border-radius: 6px/4px;
}
</style>
</head>
<body>
<div id="wrapper"></div>
<script>
let timer;
function createCalendar(id, year, month) {
const table = document.createElement('table');
const header = document.createElement('tr');
const daysOfWeek = ['пнд', 'втр', 'срд', 'чтв', 'птн', 'сбт', 'вск'];
const monthNames = [
'Январь',
'Февраль',
'Март',
'Апрель',
'Май',
'Июнь',
'Июль',
'Август',
'Сентябрь',
'Октябрь',
'Ноябрь',
'Декабрь',
];
const data = new Date(year, month, 0);
const daysInMonth = data.getDate();
const indexMonth = data.getMonth();
const currentData = new Date();
const currentDay = currentData.getDate();
const currentMonth = currentData.getMonth();
const currentFullYear = currentData.getFullYear();
let selectHtml = monthNames.reduce(
(html, nameMonth, i) =>
(html += `<option value=${i} ${
indexMonth == i ? 'selected' : ''
}>${nameMonth}`),
`<select>`
);
const yearFull = data.getFullYear();
selectHtml += `<input value=${yearFull}>`;
table.insertAdjacentHTML(
'beforeend',
`<tr><th colspan='7'>${selectHtml}</th></tr>`
);
for (const day of daysOfWeek)
header.insertAdjacentHTML('beforeend', `<th>${day}</th>`);
table.append(header);
let firstDay = (new Date(year, month - 1).getDay() + 6) % 7;
let nextDayToAdd = 1 - firstDay;
while (nextDayToAdd <= daysInMonth) {
const week = document.createElement('tr');
for (let i = 0; i < 7; i++) {
const day = document.createElement('td');
let cls = 'currentMonthWeek';
if (nextDayToAdd > 0 && nextDayToAdd <= daysInMonth) {
if (
currentMonth == indexMonth &&
currentFullYear == yearFull &&
nextDayToAdd == currentDay
) {
cls = 'currentDay';
table.querySelectorAll('th')[i + 1].className = 'currentDay';
}
day.innerHTML = nextDayToAdd;
}
cls && day.classList.add(cls);
nextDayToAdd++;
week.append(day);
}
table.append(week);
}
let div = document.getElementById(id);
div.innerHTML = '';
div.append(table);
[0, 2].forEach(n => {
let button = document.createElement('button');
button.addEventListener('click', () =>
createCalendar(id, yearFull, indexMonth + n)
);
div.append(button);
});
table.querySelector('select').addEventListener('input', function() {
createCalendar(id, yearFull, ++this.value);
});
table.querySelector('input').addEventListener('input', function() {
if (/^\d{4}$/.test(this.value))
createCalendar(id, +this.value, indexMonth + 1);
});
if (currentMonth != indexMonth || currentFullYear != yearFull) {
let button = document.createElement('button');
button.addEventListener('click', () =>
createCalendar(id, currentFullYear, currentMonth + 1)
);
div.append(button);
}
function refresh() {
window.clearTimeout(timer);
let finish = new Date().setHours(24, 0, 0, 0);
finish -= currentData;
timer = window.setTimeout(function() {
createCalendar(id, yearFull, indexMonth + 1);
refresh();
}, finish);
}
refresh();
return table;
}
let table = createCalendar('wrapper', 2019, 6);
</script>
</body>
</html>