You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为应用Bulma button样式的textarea恢复换行功能

解决Bulma中textarea加button类后无法换行的问题

直接给你的textarea添加自定义样式,覆盖.button类的限制即可,完全不需要用Sass:

  • 第一步,给textarea保留现有Bulma类的同时,新增一个自定义类(比如textarea-multiline):
<textarea class="button is-outlined has-background-black has-text-light has-text-left textarea-multiline" placeholder="Placeholder Text"></textarea>
  • 第二步,添加一段自定义CSS(内联或外部样式表都可以):
.textarea-multiline {
  white-space: pre-wrap !important;
  min-height: 100px; /* 可选,给textarea设置最小高度,更适合多行输入 */
}

核心原因是Bulma的.button类强制设置了white-space: nowrap,导致textarea无法换行。用white-space: pre-wrap就能恢复自动换行和手动换行的功能,!important是为了确保样式能覆盖Bulma的原设置。

如果想快速测试,也可以直接用内联样式:

<textarea class="button is-outlined has-background-black has-text-light has-text-left" placeholder="Placeholder Text" style="white-space: pre-wrap;"></textarea>

这样既能保留你想要的深色主题按钮样式,又能让textarea正常支持多行输入。

内容的提问来源于stack exchange,提问作者Sage Hendricks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 23:05:32