I have the following code with DOM functions which shows a text with a background color.
//Crear un div mediante DOM.
function crearCajaResumen(){
var div = document.createElement("div");
var texto = document.createTextNode("Texto");
div.setAttribute("style", "background-color: #FE775A;");
div.appendChild(texto);
document.body.appendChild(div);
}
How can you add a size (width and height) to this div? Are there attributes in the style such as width or height to be able to add it to "setAtrribute"?
It should include the following elements:
- -A title centered on the div box.
- -3 lines of text either.
- -A div size of 280x170.
- -The div / box must be aligned inside the top left.
What is the reason for the failure of dimensions and location?