Показать сообщение отдельно
  #90 (permalink)  
Старый 25.05.2021, 18:35
Аватар для Блондинка
Профессор
Отправить личное сообщение для Блондинка Посмотреть профиль Найти все сообщения от Блондинка
 
Регистрация: 24.02.2019
Сообщений: 806

по идее должно всё растягиваться, но фигушки, не могу ничего понять, по идее блок month и month vert всегда должны быть квадратом, а блоки week растягиваться, но на деле хер что растягивается, по идее если если блоки week сделать тоже флекс контейнерами то блоки day должны растягиваться но ничего не срабатывает...

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>calendar-rotate</title>
    <style type="text/css">
      #calendar_rotate {
        border: 1px solid hsl(0,0%,66%);
        padding: 5px;
        display: inline-block;
        width: 373px;
      }
      #navigation_panel { 
        border: 1px solid hsl(0,0%,66%);
        padding: 5px 10px;
        margin: 0 0 5px 0;
        display: inline-block;
        white-space: nowrap;
      }
      #background_month {
      background-color: hsl(210,100%,85%);
      display: inline-block; }
      #month_select {
      background-color: transparent;
      color: hsl(210,100%,45%);
      font: 14px serif;
      border: 1px solid hsl(210,100%,45%); }
      .month {
        border: 1px solid hsl(0,0%,66%);
        display: flex;
        flex-flow: column wrap;
        justify-content: space-between;
        width: 367px;
        height: 367px;
        padding: 1px;
      }
      .month.vert {
        border: 1px solid #ff0;
        height auto;
        display: flex;
        justify-content: space-between;
      }
      .month.vert .week {
        border: 1px solid #090;
        flex: 1 1 auto;
        align-self: stretch;
      }
      .month.vert .week .day {
        height 11.52%;
      }
      .month .week {
        border: 1px solid #00a;
        flex: 1 1 auto;
        align-self: stretch;
        width auto;
        height auto;
      }
      .month .week .day {
        width 1.947em;;
        height 1.85em;
      }
      .month,
      .month.vert .week,
      .day {
        display: inline-block;
        width: auto;
      }
      .month.vert .day {
        display: block;
        width: 1.85em;
      }
      .day {
        border: 1px solid hsl(0,0%,66%);
        line-height: 35px;
        text-align: center;
        padding: 3.5px;
        margin: 1px;
        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%);
      }
      select {
        width: 109px;
        height: 29.5px;
      }
      input { 
        border: 1px solid hsl(0,0%,66%);
        width: 54px;
        height: 25.5px;display: inline-block;
        text-align: center;
      }
      #month_minus, #year_minus { 
      width: 28px;
      text-align: center;
      border-radius: 12px 0 0 12px / 10px 0 0 10px;
      margin: 0 -6px 0 0;
      position: relative; top: 1.5px; }
      #month_plus, #year_plus {
      width: 28px;
      text-align: center;
      border-radius: 0 12px 12px 0 / 0 10px 10px 0;
      margin: 0 0 0 -6px;
      position: relative; top: 1.5px; }
      #month_minus, #month_plus, #year_minus, #year_plus, #year_input {
      background-color: hsl(210,100%,85%);
      color: hsl(210,100%,45%);
      font: 14px serif;
      border: 1px solid hsl(210,100%,45%);}
    </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>
        <div class="month vert"></div>
        <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 += '<div class="week">';
                html += '<div class="day">' + this.days[i] + '</div>';
                if (j == 6) html += '</div>';
              }
              this.element.innerHTML = html;
            },
            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('change', load);
          document.getElementById('year_input').addEventListener('change', 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>
Ответить с цитированием