@AlexandraWeather

Как мне исправить анимацию?

Попыталась сделать маленький самодельный свичер на css. А
нимация почему-то получается не плавная. Помогите понять, что я делаю не так.
  • Вопрос задан
  • 49 просмотров
Решения вопроса 1
sergey155
@sergey155
*,
    *::before,
    *::after {
      box-sizing: border-box;
    }

    .visually-hidden {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      border: 0;
      padding: 0;
      white-space: nowrap;
      clip-path: inset(100%);
      clip: rect(0 0 0 0);
      overflow: hidden;
    }

    .wrapper {
      width: fit-content;
      padding: 50px;
      margin: 20px auto;
      outline: 2px dashed tomato;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .check-label {
      position: relative;
      display: inline-block;
      width: 50px;
      height: 20px;
      background-color: lightgrey;
      border: 1px solid grey;
      border-radius: 10px;
      box-shadow: 1px -2px 3px 2px rgba(0, 0, 0, 0.2) inset;
      background: linear-gradient(to right, blue, navy);
      background-repeat: no-repeat;
      background-size: 80%;
      background-position: -50px;
      transition: background-position 0.2s ease;
    }

    .check-label::before {
      content: "";
      display: inline-block;
      position: absolute;
      width: 23px;
      height: 23px;
      top: 50%;
      transform: translateY(-50%);
      left: 0;
      background-color: gainsboro;
      border: 5px solid dimgrey;
      border-radius: 50%;
      transition: left 0.25s ease;
    }

    #check:checked ~ .check-label {
      background-position: left;
    }

    #check:checked ~ .check-label::before {
      left: 27px;
    }
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы