Log in

View Full Version : Cross-browser font height



Rain Lover
03-21-2019, 07:53 AM
As you see the outline is collapsed in the following sample:


var input = document.getElementById('input');
var output = document.getElementById('output');
input.addEventListener('input', function() {
output.value = input.value;
});

output {
display: block;
font: 20px Arial;
outline: 1px solid green;
}

<input id="input">
<output id="output"></output>

DEMO (https://jsfiddle.net/Mori/stybgjk0/)

How can I prevent it? Do I need to give the output a fixed height? If so, what value should I give to the height if I want it to be just as high as the text height — not an arbitrary number? Is there a cross-browser solution?

molendijk
03-21-2019, 03:31 PM
HTML:

<output id="output">&nbsp;</output>

mitza.dragan
03-28-2019, 07:41 AM
To prevent the output box do disappear when delete everything using backspace update the css with :

output {
display: block;
font: 20px Arial;
outline: 1px solid green;
min-height: 27px;
}
and also don't need the

<output id="output">&nbsp;</output>
you cand use:

<output id="output"></output>

Hope that is what you needed.