Using CSS calc() with .animate()

Viewed 2024

I'm trying to make a little animation but I'm failing to make it responsive, because "calc()" seems to not work with .animate. Is there another solution to this here?

if (time == 1) {
  $("#message").animate({ marginTop: "calc(-15px + .8vw)" });
} else {
  $("#message").animate({ marginTop: "calc(0px + .8vw)" });
}

With great and best regards, BERNARDO

EDIT: I'm trying to animate a message that appears on my website onchange() of a dropdown menu. It should be responsive so that's why I'm using calc().

<a>Time: </a><select id="time" onchange="setTime()" name="time" required>
                    <option value="1" selected>-</option>
                    <option value="3">-</option>
              </select></br>

So is there like an alternative to make it responsive on another way without calc()?

2 Answers
Related