Today, I experimented with using relative values in jQuery's .css()
function.
$block.css({'margin-left': '-=100%'});
This resulted in the following style for the div:
<div class="block" style="margin-left: -100px;">
I noticed that jQuery doesn't properly handle percentages, which led me to research the issue. According to the jQuery documentation:
Starting from jQuery 1.6, .css() supports relative values similar to .animate(). Relative values are strings beginning with += or -= to increment or decrement the current value.
A bug related to this has been reported here, but I find it a bit confusing and am unsure how to solve it.
Does anyone know how to modify this code:
$block.css({'margin-left': '-=100%'});
To achieve this result:
<div class="block" style="margin-left: -100%;">
And then progress to:
<div class="block" style="margin-left: -200%;">
And so forth... I understand that this can be accomplished using .animate()
, but my goal is to avoid it and utilize pure CSS for hardware acceleration.