+ 1

Can we make a block (circle, square) with JS only (no canvas)?

Can we make a block with colors with JS (without canvas) Something like... red rectangle?

6th Jul 2019, 8:25 AM
Ginfio
Ginfio - avatar
3 Answers
+ 4
Yes, you cam, but canvas might be better. You can create DOM elements with javascript, and manipulate them. The following example will make a red circle with the width and height of the 10th of the screen width (if there is an element with the ID "container"): const circle = document.createElement("div"); circle.stype.width = "10vw"; circle.style.height = "10vw"; circle.style["border-radius"] = "50%"; circle.style.background = "#F00"; document.querySelector("#container").appendChild(circle);
6th Jul 2019, 8:44 AM
Airree
Airree - avatar
+ 2
But it's only javascript
6th Jul 2019, 8:47 AM
Airree
Airree - avatar
+ 1
Airree Can JS by itself make a block (no canvas still). no html / css. JS by itself?
6th Jul 2019, 8:46 AM
Ginfio
Ginfio - avatar