【问题标题】:Inline form not working correctly内联表单无法正常工作
【发布时间】:2016-02-03 14:50:11
【问题描述】:

尝试使用 form-inline 类从引导程序中获取内联表单。但是,我遇到了一些意外行为,我使用的代码与 Boostrap 官方页面上列出的代码完全相同。

这是我得到的:

代码:

@using (Html.BeginForm("Edit", "Index", FormMethod.Post, new { @class = "form-inline" }))
{
    <div class="form-group">
        <label for="new-value">Enter new value: </label>
        <input type="text" id="new-value" class="form-control" />
    </div>
    <div class="checkbox">
        <label>
            Public: <input type="checkbox" />
        </label>
    </div>
    <input type="submit" class="btn btn-primary" />
}

当我从文本框中删除 form-control 类时,我得到了想要的结果,但是我没有很酷的文本框:

我知道来自引导程序的警告:

这仅适用于视口中至少 768 像素宽的表单。

但这是在大屏幕上,表单宽度为 1160px。

【问题讨论】:

    标签: c# css asp.net twitter-bootstrap


    【解决方案1】:

    我已经编辑了您的代码。 希望这是你想要的!

    HTML

    <form class="form-inline">
      <div class="form-group">
        <label for="new-value">Enter new value: </label>
        <input type="text" id="new-value" class="form-control" />
      </div>
      <div class="form-group">
        <div class="checkbox">
          <label> Public:
            <input type="checkbox" />
          </label>
        </div>
      </div>
      <div class="form-group">
        <input type="submit" class="btn btn-primary" />
      </div>
    </form>
    

    检查此工作模型http://www.bootply.com/ZWGwdEcnva

    【讨论】:

    • 感谢您的回复,但这是我得到的代码,一旦.net 编译了帮助程序。唯一的区别是&lt;form action="/" class="form-inline" method="post"&gt;,这使得差异为零。我也尝试将文本输入嵌套在标签内,但没有产生任何结果。
    • 我不知道.net。我把每个项目都放在&lt;div class="form-group"&gt; 中,这样每个表单组都对齐中心
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-18
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    相关资源
    最近更新 更多