Below I have this piece of JS code. When the resolution of the screen is between 995px and 1200px, then the css animation of transform: translate should be 22%. How can I do this?
CSS code:
.to_be_center {
        position: relative;
        transform: translate(-27%, 25%);
}
JS code:
function resolution() {
    width = window.screen.availWidth;
    if ((width>=995) && (width<1200)){
        document.getElementsByClassName("to_be_center").style.transform= "translateX(14%)"; 
    }
}
resolution();
I call the function in body - <body onload="resolution()">.
 
     
    