'Why doesn't my element move along the X axis?
I have tried a lot of ways but they don't seem to apply to my scenario. I want the anchor element to move 20px along the x axis. HTML:
<!-- When this is clicked moveElement() is initiated to translateX by 20px -->
<a href="#" id="aButton" class="getStarted" onclick="moveElement()">Get started</a>
Javascript:
function moveElement() {
let btn = document.getElementById("aButton");
btn.style.translateX = "20px";
// I also tried transform = 'translateX("20px")' but it did not work.
}
Solution 1:[1]
translateX is not a valid CSS property. Perhaps you mean:
btn.style.transform = "translateX(20px);";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | joe mama |