'make textarea not wrap when using specific symbols [duplicate]
I have a textarea I am using for an ASCII art 3d game and when there are different types of characters, it wraps even though I have set all the css wrapping stuff to no wrap. It's only meant to wrap at the end of each line and not in between different characters.
textarea {
width: 300px;
height: 5em;
font-size: 14px;
overflow: hidden;
overflow-wrap: break-word;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
}
#expected {
width: 300px;
height: 5em;
font-size: 14px;
font-family: monospace;
outline: 1px solid gray;
border-radius: 1px;
padding: 2px;
}
<p>actual:</p>
<textarea wrap="hard">aaaaaaaaaaaaaa((((((((((((((((((((((((((((((>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</textarea>
<p>expected:</p>
<div id="expected">aaaaaaaaaaaaaa(((((((((((((((((((((((<br>(((((((>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<br><<<<<<<<<<<<<<<<<<<<<<<</div>
I have tried every other question but all the answers just did words and not symbols.
Solution 1:[1]
A solution is to use the css calc() to convert it to ch unit.
textarea {
width: calc(300px - 0px);
height: 200px;
font-size: 14px;
}
<textarea wrap="hard">aaaaaaaaaaaaaa((((((((((((((((((((((((((((((
expected:
aaaaaaaaaaaaaaaaaaaa999999999999999999999999999999999999fffffffffffffffffffffffffffffffssssssssssssssssssssssssssss11111111111111111111111111</textarea>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
