1

In my library jQuery Terminal I have issue with CSS on Codpen (ASCII art) when opening in Chrome Underscores is not always visible,

enter image description here

Codepen use iframe, I've tested locally and iframe looks ok. Codpen also looks ok in FireFox. If you open Codpen debug mode it also looks ok.

The CSS copied from developer tools (except ::selection)

.terminal .terminal-output div span {
    display: inline-block;
}
.terminal .terminal-output > div:not(.raw) div {
    white-space: nowrap;
}
.terminal .terminal-output > div > div {
    min-height: calc(var(--size, 1) * 14px);
}
.terminal, .terminal-output > :not(.raw) span,
.terminal-output > :not(.raw) a,
.terminal-output > :not(.raw) div,
 .cmd, .cmd span, .cmd div {
    font-size: calc(var(--size, 1) * 12px);
    line-height: calc(var(--size, 1) * 14px);
}
.terminal, .terminal-output > :not(.raw) span,
.terminal-output > :not(.raw) a,
.terminal-output > :not(.raw) div, 
.cmd, .cmd span, .cmd div {
    color: var(--color, #aaa);
    background-color: var(--background, #000);
}
.terminal, .terminal-output > :not(.raw) span, 
.terminal-output > :not(.raw) a, 
.terminal-output > :not(.raw) div, 
.cmd, .cmd span, .cmd div {
    font-family: monospace;
    color: #aaa;
    background-color: #000;
    font-size: 12px;
    line-height: 14px;
}
.terminal .terminal-output > div:not(.raw) div {
    white-space: nowrap;
}
Style Attribute {
    --char-width: 7.23011;
}
.terminal, .cmd {
    box-sizing: border-box;
    cursor: text;
}

Here is the codepen https://codepen.io/jcubic/pen/wQjaZv not sure If this is only on Linux didn't tested this on MacOSX or Windows.

I can fix the issue by adding padding-bottom: 1px; or margin-bottom: 1px to .terminal-output > div > div but I want to know why this is happening? Why second line have underscores visible but not the first one?

I didn't use any reset or normalize css in this pen.

EDIT:

I've also have this css

/* FireFox hack */
@supports (-moz-animation: foo) {
    .terminal,
    .terminal .terminal-output > :not(.raw) span,
    .terminal .terminal-output > :not(.raw) a,
    .terminal .terminal-output > :not(.raw) div,
    .cmd,
    .cmd span,
    .cmd div {
        line-height: calc(var(--size, 1) * 13px);
    }
}

that suppose to fix some firefox issue, but it seems it works without it.

When I investigated in dev tools in Chrome/Linux/Codpen I have ASCII art line that look like this (in computed style):

line div parent {
   height: 13.9915px;
}
span child {
   height: 13.6364px;
}

and in Firefox or in Chrome outside of Codepen (also in Debug mode outside of Codpen iFrame) I have:

line div parent {
   height: 14px;
}
span child {
   height: 14px;
}

and when I hover over line div I got height 15.

so the underscore is outside of div but I have this css:

.terminal .terminal-output > div > div {
    min-height: calc(var(--size, 1) * 14px);
}

it it should be at least 14px, why it have 13.9915px?

I've did one more testing, I've cloned codepen editor and inserted debug page as iframe source, save it and uploaded to my server and it also work fine, the divs are not cut off and the height is 14px.

EDIT2:

I've resolved the issue by using:

.terminal .terminal-output > div > div {
    min-height: calc(var(--size, 1) * 15px);
}

15px instead of 14px but still want to know why this is happening and why only on Codepen/Linux/Chromium.

jcubic
  • 61,973
  • 54
  • 229
  • 402
  • Works fine in Chrome on Windows. – Rainbow Dec 02 '18 at 12:55
  • I've tested this in Fedora GNU/Linux – jcubic Dec 05 '18 at 08:38
  • I've got reply from Codepen support and they said that it work fine on Ubuntu/Chromium. I think that my fix will not harm anything. Since the div had height of 15px in Firefox anyway. – jcubic Dec 06 '18 at 18:06
  • So I've installed Google Chrome and it was working fine, but Chromium Incognito mode was not working, so I've created new guest profile. And it's **WORKING FINE**. So the problem it seems is in config for my profile. I will just ignore the error in CodePen then since only I have it. – jcubic Jan 07 '19 at 22:35

1 Answers1

1
.terminal, 
.terminal-output > :not(.raw) span, 
.terminal-output > :not(.raw) a, 
.terminal-output > :not(.raw) div, 
.cmd, 
.cmd span, 
.cmd div {
  font-size: calc(var(--size, 1) * 20px);
  line-height: calc(var(--size, 1) * 24px);
}

The underscore is cut of, because the limit of the line height was met and every line has a background-color. If you increase the line-height as well, it will work again

Here a simplified example:

p {
  white-space: pre;
  font-family: monospace;
}
#one {
  font-size: 14px;
  line-height: 7px;
}

#two {
  font-size: 14px;
  line-height: 8px;
}

span {
  background: white;
  
}
<p id="one">
  <span>      __ _____                     ________                              __</span><br>
  <span>     / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /</span><br>
  <span> __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /</span><br>
  <span>/  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__</span><br>
  <span>\___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/</span><br>
  <span>          \/              /____/                                  v. 2.0.1</span>
</p>
<p id="two">
  <span>      __ _____                     ________                              __</span><br>
  <span>     / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /</span><br>
  <span> __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /</span><br>
  <span>/  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__</span><br>
  <span>\___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/</span><br>
  <span>          \/              /____/                                  v. 2.0.1</span>
</p>
yunzen
  • 32,854
  • 11
  • 73
  • 106
  • Right now I'm testing in Chrome/Windows 7 and your snippet look like this https://i.stack.imgur.com/YovWi.png – jcubic Dec 07 '18 at 12:17
  • I think you're right, adding `background: transparent` to span make my underscores reappear. But the code snippets don't work, It also looks the same in affected Chromium/Fedora. – jcubic Dec 07 '18 at 12:25
  • I think that line-height should be `3px larger` so it should be `line-height: calc(var(--size, 1) * 12px + 3px);` – jcubic Dec 07 '18 at 12:36