I'm trying to create a console/terminal like element for my website.
Basically, I want users to type in commands and give output. When the output is generated, it might be a couple of lines of info.
So when new output is displayed, I want to scroll down to the "new-output" element automatically.
<div class="container center">
<form class="about-form">
<input type="text" class="about-input">
</form>
<div class="terminal">
<div class="terminal-bar"><span class="title">info ><span class="terminal-height">terminal</span></span>
</div>
<p class="prompt">Name: Ruan Kranz</p>
<p class="prompt">ROLE: full stack web developer</p>
<p class="prompt">Level: 5+ years experience</p>
<p class="prompt">Personality: Curious, passionate, analytical</p>
<p class="prompt">Skills: Back-end, Front-end, DevOps, Scripting, Design</p>
<p class="prompt">Interests: Coding, gaming, bitcoin, travel, reading, learning</p>
<p class="prompt"></p>
<p class="prompt">Type the words above ^1000</p>
<p class="prompt">To leave type "exit" ^1000</p>
<p class="prompt">Type "HELP" for a list of commands ^1000</p>
<p class="prompt output new-output"></p>
</div>
I do this using velocity.js
$('.new-output').velocity(
'scroll'
), {
duration: 100
}
And this function works perfectly if the .terminal is not in a container with a max-height.
I have the following CSS for the .center container
.center {
margin: auto;
max-width: 800px;
min-height: 400px;
}
And the .terminal
.terminal {
position: relative;
display: block;
margin: auto;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.8) 0px 20px 70px;
clear: both;
max-height: 400px;
overflow-x: hidden;
overflow-y: visible;
}
Why is it not working when I try to scroll down the user when using a container with a fixed height, and how can I achieve the desired outcome? I don't want the elements height (or size) to change, but I want to scroll the user down when new output is generated.