In my code you can see that if you add enough elements, some of the content goes off the screen. I'm fine with the content going off the bottom of the screen, because it is still accessible. I don't want it to go off the top of the screen because then you can't access some of the elements.
Is this possible with pure CSS (without using JavaScript)?
Before:
After:
function add() {
items = document.getElementById("items");
input = document.getElementById("input").value;
x = document.createElement("p");
x.innerHTML = input;
items.appendChild(x);
}
html,
body {
margin: 0;
height: 100%;
}
.centered {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
<body class="centered" id="items">
<h1>TODO:</h1>
<input type="text" placeholder="Enter Items Here" id="input" />
<input type="button" onclick="add();" value="add" />
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
<p>Paragraph.</p>
</body>