I saw a little demo the other day called HTML5 Terminal. It has some functionality, but it seems like it’s just kinda for fun. That said, I loved the aesthetic of it! Blurry monospace type with visible monitor lines and a glowing green background — nice!
Let’s re-create that, bit-by-bit.
A radial gradient is perfect for the glowing green background:
body {
background-color: black;
background-image: radial-gradient(
rgba(0, 150, 0, 0.75), black 120%
);
height: 100vh;
}
I’m so used to using <pre><code>
to display space-formatted text (like code), but you could say terminal text isn’t always code, so I like the use of <pre><output>
here.
Might as well use a nice monospace font:
body {
...
color: white;
font: 1.3rem Inconsolata, monospace;
}
The text on the demo appears a bit blurry. We could go with a slight filter like filter: blur(0.6px);
, but it seems blurring that way comes out either too blurry or not blurry enough. Let’s try using text-shadow
instead:
body {
...
text-shadow: 0 0 5px #C8C8C8;
}
Now on to those monitor lines! Ideally, they should sit on top of the text, so let’s use an ::after
pseudo-element that’s absolutely positioned over the whole area and use a repeating linear gradient for the lines (because it’s always nice to avoid using images if we can):
body::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: repeating-linear-gradient(
0deg,
rgba(black, 0.15),
rgba(black, 0.15) 1px,
transparent 1px,
transparent 2px
);
}
You can see these faint black lines on white here:
And then over our original green burst background to complete the look:
It’s a nice touch to add a fun selection style and remove the blurring for clarity when selecting:
::selection {
background: #0080FF;
text-shadow: none;
}
Complete demo:
See the Pen Terminal Output by Chris Coyier (@chriscoyier) on CodePen.
Ouch… doesn’t work in Firefox.
Ouch?
Works fine here.
Looks good from here also, even on my Linux box.
The text selection does not seem to work on Firefox. Also, the following line in the body::after seems to be missing a comma (” rgba(black, 0.15) 1px,”).
Outside of that, this was great! Thank you for taking to time to make this tutorial!
This would work great as a Hyper theme :)
Exactly what I was thinking!
Also, add
pointer-events: none;
on the::after
pseudo-element to allow cursor-based selection on Firefox (and maybe other browsers I haven’t tested).Ha ha ha! you didn’t say the magic word!
My personal, perpetually WIP website uses this type of UI. The linear gradient approach for the CRT “scan lines” is a nice touch. If I ever get to working on my site again, I might try that, as opposed to using an svg.
This was a great walkthrough. Thanks!
Cool! There’s a similar thing as native app for mac and iOS, if you like to use this primarily => http://www.secretgeometry.com/apps/cathode/
Oh my god this is exactly what i was searching for…. (so we can make this kind of stuff: http://asterion.online/inspiration/linearAdventure/)
It mostly works for me in Firefox, but I can’t select the text. Commenting out the “monitor lines” makes text selectable, so I guess Firefox can’t “see” through them to select.
You should write “pointer-events: none;” in the monitor lines’s declaration block.
I guess the pointer events got added at some point, because today I can select in Firefox in the demo.
Awesome, I was looking this, and it’s perfect.
But, if I put this terminal in a div, instead the whole body, those monitor lines are a problem because overflow the div. And yep, overflow:hidden didn’t work.