Textarea Height在Bootstrap模式中不起作用

发布于 2025-02-07 13:32:46 字数 2195 浏览 0 评论 0原文

我在我的ASP.NET Web应用程序中使用以下代码有一个模态对话框:

        <div class="modal fade" id="mdlNewNote" tabindex="-1" aria-labelledby="mdlNewNoteLabel" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="mdlNewNoteLabel">Add New Note</h5>
                        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <form class="was-validated" id="frmNote" name="frmNote" method="post">
                        <div class="modal-body">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="form-floating col-sm-12">
                                        <textarea class="form-control" rows="10" id="NoteBody" name="NoteBody"></textarea>
                                        <label for="NoteBody">Notes</label>                                    
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary">Save</button>
                            <button type="button" class="btn btn-success" data-bs-dismiss="modal">Close</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

在该块中,有一个&lt; textarea&gt;元素,我希望根据模态在其行计数中进行尺寸,设置为10。但是,它实际上仅在模态中显示三行,如下所示:

“浏览器中的模态是什么样的”

我如何修复它,以便&lt; textarea&gt;元素是应有的(基于给出的行数)而不是现在显示的3行?

I have a modal dialog in my ASP.NET Web application using the following code:

        <div class="modal fade" id="mdlNewNote" tabindex="-1" aria-labelledby="mdlNewNoteLabel" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="mdlNewNoteLabel">Add New Note</h5>
                        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <form class="was-validated" id="frmNote" name="frmNote" method="post">
                        <div class="modal-body">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="form-floating col-sm-12">
                                        <textarea class="form-control" rows="10" id="NoteBody" name="NoteBody"></textarea>
                                        <label for="NoteBody">Notes</label>                                    
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary">Save</button>
                            <button type="button" class="btn btn-success" data-bs-dismiss="modal">Close</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

In that block there is a <textarea> element that I want to be sized inside the modal according to its row count, which is set at 10. However, it only actually displays three rows in the modal, as shown below:

What modal looks like in browser

How do I fix it so that the <textarea> element is as tall as it should be (based on number of rows it is given) rather than the 3 rows it shows now?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小伙你站住 2025-02-14 13:32:46

使用Bootstrap,您必须使用以下方式覆盖高度:

.specific-textarea { height: 100% !important; }

CF:
https://stackoverflow.com/a/58398265/12172974

With bootstrap, you have to override the height by using:

.specific-textarea { height: 100% !important; }

cf:
https://stackoverflow.com/a/58398265/12172974

十年不长 2025-02-14 13:32:46

使用html进行文本方面的尺寸。

<label for="story">Tell us your story:</label>

<textarea id="story" name="story"
          rows="5" cols="33">
It was a dark and stormy night...
</textarea>

资料来源: https:// https://developer.mozilla.org/en--en------------- us/doc/web/html/element/textarea

Use HTML for textarea sizing.

<label for="story">Tell us your story:</label>

<textarea id="story" name="story"
          rows="5" cols="33">
It was a dark and stormy night...
</textarea>

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文