You are attempting to set multiple values in one line, this isn't possible.
document.getElementById('block').style.position = "absolute";
document.getElementById('block').style.left = document.getElementById('block').style.top = "50%";
document.getElementById('block').style.transform = "translate(50%, 50%)";
If you just want the styles to be applied all the time, you can add it right into the div's style attribute:
<div id="block" style="background-color:#000000;height:100px;width:100px;position: absolute; left: 50%; top: 50%; transform: translate(50%, 50%);"></div>
But this is ugly, you should separate styles from markup:
#block {
background-color: #000000;
height: 100px;
width: 100px;
position: absolute;
left: 50%; top: 50%;
transform: translate(50%, 50%);
}
Also, I think you want position: fixed
, not absolute
.