为什么 'white-space:normal' 属性没有按 <textarea> 中的预期工作?

问题描述 投票:0回答:1

我知道使用空白:正常可以将多个空格折叠为一个,但它似乎在谷歌浏览器中不起作用。

这是我的代码。

            <div>
                <label style="display: block;" for="textarea6">white-space: normal</label>
                <textarea id="textarea6" name="textarea6" rows="5" cols="33" style="white-space: normal;">j jj  jjj </textarea>
                <p style="white-space: normal;">j jj  jjj </p>
            </div>

像这样。

All spaces have been reserved

下面列出了所有 CSS 样式。

element.style {
    white-space: normal;
}


textarea {
    font-style: ;
    font-variant-ligatures: ;
    font-variant-caps: ;
    font-variant-numeric: ;
    font-variant-east-asian: ;
    font-variant-alternates: ;
    font-weight: ;
    font-stretch: ;
    font-size: ;
    font-family: monospace;
    font-optical-sizing: ;
    font-kerning: ;
    font-feature-settings: ;
    font-variation-settings: ;
    text-rendering: auto;
    color: fieldtext;
    letter-spacing: normal;
    word-spacing: normal;
    line-height: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    text-align: start;
    appearance: auto;
    -webkit-rtl-ordering: logical;
    resize: auto;
    cursor: text;
    white-space-collapse: preserve;
    text-wrap: wrap;
    overflow-wrap: break-word;
    background-color: field;
    column-count: initial !important;
    writing-mode: horizontal-tb !important;
    margin: 0em;
    border-width: 1px;
    border-style: solid;
    border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
    border-image: initial;
    padding: 2px;
}

怎样才能达到预期的“white-space:normal”效果?

css textarea
1个回答
0
投票

这个

white-space-collapse: preserve;
来自哪里?那就是保留空格字符。如果您删除它或可能用
white-space-collapse: collapse;
覆盖它,它应该可以工作。

© www.soinside.com 2019 - 2024. All rights reserved.