Issue
Neither style top nor bottom is applied. How can I fix this?
let btn = document.createElement("button");
btn.textContent = "Button";
btn.style.position = "fixed";
if (this.anchorBottom) {
btn.style.bottom = this.y;
console.log(true)
}
else {
btn.style.top = this.y;
}
btn.style.right = 0;
document.body.appendChild(btn);
Solution
Provide a unit as well.
let btn = document.createElement("button");
btn.style.position = "fixed";
if (this.anchorBottom) {
btn.style.bottom = `${this.y}px`;
console.log(true)
} else {
btn.style.top = `${this.y}px`;
}
btn.style.right = '0px';
document.body.appendChild(btn);
Remember, you're not limited to only using px values.
Answered By - evolutionxbox
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.