I am trying to make a function that creates divs containing text and puts them in another div called "history".
The problem is that the text in the divs come out as single lines like this
2/2=1
instead of this
2/2
=1
It may also be caused by the height limitation of the div, if so how do I automatically adjust the size with javascript.
function creatediv() {
var element = document.createElement("div");
var doc = "2/2" + "\n" + "=1";
const es = element.style;
element.appendChild(document.createTextNode(doc));
document.getElementById('history').appendChild(element);
es.backgroundColor = "azure";
es.margin = "3px"
es.borderRadius = "5px";
es.padding = "2px"
}
white-space: pre;.<br/>instead of\nand set innerHTMLwhite-space:no-wrapwould help force it stay on one line might cause overflow though