Encountering CSS margin issues when adding new divs. Desiring a large margin between the Create Div button and minimal margin between Example Text Here.
JS:
document.getElementById("createTask").addEventListener("click", myFunction);
function myFunction() {
var div = document.createElement('div');
div.innerHTML = "Example Text Here Example Text Here";
div.setAttribute('class', 'myclass'); // ensure that myclass has appropriate css styles
document.body.appendChild(div);
}
CSS:
div {
border-top: 20px;
margin-left: 200px;
margin-top: 20px;
width: 950px;
padding: 10px;
word-spacing: 110px
}
h1 {
margin-top: 200px;
}
JS:
document.getElementById("createTask").addEventListener("click", myFunction);
function myFunction() {
var div = document.createElement('div');
div.innerHTML = "Example Text Here Example Text Here";
div.setAttribute('class', 'myclass'); // make sure myclass includes relevant css styles
document.body.appendChild(div);
}
CSS:
div {
border-top: 170px solid transparent;
margin-left: 200px;
margin-top: 20px;
width: 950px;
padding: 10px;
word-spacing: 110px
}
h1 {
margin-top: 200px;
}
Desire a similar margin between Create Div button and Example Text Here like in this example, while avoiding excessive space between multiple occurrences of Example Text: https://jsfiddle.net/stackquestion2021/y0dm2jao/3/
Seeking larger margin between Create Div and Example Text Here, with perfect spacing between different Example Text elements. https://jsfiddle.net/stackquestion2021/e5nvdh4p/5/