2017-05-15 22 views
0

当按下输入/返回键时,我似乎已经失去了默认的textarea行为。我想按下这个键将光标移动到下一行,但它只是插入一些空格。必须是我的CSS规则中的东西,但我不知道它是什么。输入/返回键没有移动到textarea的新行

button, input, textarea, select { 
 
    outline: none; 
 
    box-shadow: none; 
 
    -webkit-appearance: none; 
 
    -moz-appearance: none; 
 
    appearance: none; 
 
    -webkit-border-radius: 0; 
 
    border-radius: 0; 
 
    color: #3b3b3b; 
 
    font-family: inherit; 
 
    font-size: inherit; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
    white-space: nowrap; 
 
    margin: 0; 
 
    padding: 0.2em 0.4em; 
 
    width: 100%; 
 
    -webkit-transition: all 0.3s ease-in-out; 
 
    transition: all 0.3s ease-in-out; 
 
    border-width: 1px; 
 
    border-style: solid; 
 
    border-color: #d4d4d4; 
 
    background: #fff; 
 
} 
 
textarea { 
 
    height: 8em; 
 
    vertical-align: top; 
 
    overflow: auto; 
 
}
<textarea id="Textarea1" placeholder="Text area"></textarea>

+1

对我来说好像在铬上在mac上 –

+0

你使用什么浏览器?有没有任何CSS规则被继承? – bdkopen

+0

@bdkopen不,你可以看到上面的嵌入代码片段,看看有没有CSS规则被继承。我在Mac上使用Safari。 – JROB

回答

2

取出white-space: nowrap;上线14

0

更新:我发现一个textarea的默认行为是white-space: pre;,所以我更新了我的CSS规则如下,它的工作原理现在罚款:

button, input, textarea, select { 
 
    outline: none; 
 
    box-shadow: none; 
 
    -webkit-appearance: none; 
 
    -moz-appearance: none; 
 
    appearance: none; 
 
    -webkit-border-radius: 0; 
 
    border-radius: 0; 
 
    color: #3b3b3b; 
 
    font-family: inherit; 
 
    font-size: inherit; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
    white-space: nowrap; 
 
    margin: 0; 
 
    padding: 0.2em 0.4em; 
 
    width: 100%; 
 
    -webkit-transition: all 0.3s ease-in-out; 
 
    transition: all 0.3s ease-in-out; 
 
    border-width: 1px; 
 
    border-style: solid; 
 
    border-color: #d4d4d4; 
 
    background: #fff; 
 
} 
 
textarea { 
 
    height: 8em; 
 
    vertical-align: top; 
 
    overflow: auto; 
 
    white-space: pre; 
 
}
<textarea id="Textarea1" placeholder="Text area"></textarea>