【问题标题】:Setting the width of a Textarea in Bootstrap 3在 Bootstrap 3 中设置 Textarea 的宽度
【发布时间】:2016-03-10 19:36:53
【问题描述】:

我一直在寻找一种方法来让我的“textarea”在它的列中达到 100%。我已经看到了几种不同的方法(我都无法使用)在 Bootstrap 中将“textarea”扩展到 100%。我拥有从自定义内联 CSS 样式到使用 class="form-control col-lg-12" 到覆盖 Bootstrap 的 CSS 的所有内容。

任何人有一个可行的建议,允许流体调整大小?

这是我的代码。现在宽度稍微超过占位符文本。

<div class="row">
            <div class="col-lg-7">
                <h2>@Model.EmployeeName</h2>
                <h3>Employee #: @Model.EmployeeNumber</h3>

                <h5>(Optional): Exception Log comments related to this shift for your Supervisor/Time Keeper.</h5>
                <textarea rows="2" placeholder="Exception Log comments."></textarea>
            </div>
            <div class="col-lg-5 text-right">
                <div ng-controller='TimeCtrl'>
                    <h2>{{ clock | date:'fullDate'}}</h2>
                    <h1>{{ clock | date:'HH:mm:ss'}}</h1>
                    <input type="submit" class="btn btn-xxlarge btn-success" value="Punch In" />
                </div>
            </div>
        </div>

【问题讨论】:

    标签: css twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    我相信引导程序自己的表单元素类(表单控件)将使表单元素占据它们所在列的整个宽度。

    <textarea class="form-control"></textarea>
    

    【讨论】:

    • 我正要写这个
    • 似乎对我不起作用。我在研究期间尝试了建议,唯一的区别是在其中设置了一个列。这是我在 class="form-control col-lg-6" 之前尝试过的
    • 你能用 jsfiddle 之类的东西重现这个问题吗?
    • 这里是你的代码 + 在 textarea 上使用表单控件的小提琴。 jsfiddle.net/sL67rkLs
    【解决方案2】:

    class="form-control" 必须工作。如果它不起作用,则意味着在 css 文件中的某处,max-width 属性设置为限制宽度的文本区域。在这种情况下,请检查 site.css 文件并删除 max-width 属性。

    【讨论】:

      【解决方案3】:

      只需向 textarea 添加一个“表单控件”类。如果您在小屏幕上工作,col-lg-7 和 col-lg-5 会覆盖所有窗口。

      而且您的列文本alings 是不同的。您可能会在屏幕上看到 col-sm-12。

      <textarea class="form-control" rows="2" placeholder="Exception Log comments."></textarea>
      

      【讨论】:

        【解决方案4】:

        如果你只是添加一些自定义 CSS,你可以强制它使用整个容器宽度

        min-width: 100%
        max-width: 100%
        

        但是,使用引导类“form-control”也可以完成此操作

        【讨论】:

        • 重置这些值是引导程序的关键。有见地。谢谢。
        【解决方案5】:

        如果您想要 100% 的宽度,只需将 form-control 类添加到您的 textarea,无需添加 col-lg-12,因为 form-control 类将父元素的 100% 宽度提供给元素。

        <textarea class="form-control" rows="4" placeholder="Exception Log comments."></textarea>
        

        【讨论】:

          猜你喜欢
          • 2014-02-11
          • 2016-12-14
          • 1970-01-01
          • 2015-11-05
          • 1970-01-01
          • 1970-01-01
          • 2021-04-15
          • 1970-01-01
          • 2012-11-26
          相关资源
          最近更新 更多