【问题标题】:Aligning two forms and other buttons inline内联对齐两个表单和其他按钮
【发布时间】:2018-11-05 07:00:41
【问题描述】:

我有两个表单,每个表单都有多个隐藏字段和一个提交按钮。 我的目标是使用引导程序将这些表单与其他两个普通按钮水平(内联)对齐。 到目前为止,这是我尝试过的:

    <div class="container">
    <div class="row">
        <div class="col-xs-6">
            <a class="btn btn-primary" href="/employees/new">Add new Employee</a>
            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
            <form class="form-inline" action="../reports/pdf/employees" method="GET">
                <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
                <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
                <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
                <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
                <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
                <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
                <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
                <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
                <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
                <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
                <button class="btn btn-primary" type="submit">Print pdf report</button> 
        </form>
        <form action="../reports/csv/employees" method="GET">
                <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
                <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
                <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
                <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
                <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
                <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
                <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
                <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
                <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
                <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
                <button class="btn btn-primary" type="submit">Print csv report</button> 
        </form>
    </div>

【问题讨论】:

  • 请展示您的尝试。

标签: twitter-bootstrap-3


【解决方案1】:

修复:将form-inline 添加到第二个表单

注意:

  1. 表单是块项目 - 通过 css 或样式更改为 inline-block。
  2. 按钮仍然环绕,可能需要将col-xs-6 更改为更宽的东西

form.form-inline {
  display: inline-block
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="col-xs-12">
      <a class="btn btn-primary" href="/employees/new">Add new Employee</a>
      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
      <form class="form-inline" action="../reports/pdf/employees" method="GET">
        <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
        <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
        <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
        <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
        <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
        <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
        <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
        <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
        <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
        <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
        <button class="btn btn-primary" type="submit">Print pdf report</button>
      </form>
      <form class="form-inline" action="../reports/csv/employees" method="GET">
        <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
        <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
        <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
        <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
        <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
        <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
        <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
        <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
        <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
        <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
        <button class="btn btn-primary" type="submit">Print csv report</button>
      </form>
    </div>
  </div>
</div>

【讨论】:

    【解决方案2】:

    <!DOCTYPE html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!-->
    <html class="no-js">
    <!--<![endif]-->
    
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    
        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <style>
            form.form-inline {
                display: inline-block
            }
        </style>
    </head>
    
    <body>
        <!--[if lt IE 7]>
                <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
            <![endif]-->
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <a class="btn btn-primary" href="/employees/new">Add new Employee</a>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
                    <form class="form-inline" action="../reports/pdf/employees" method="GET">
                        <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
                        <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
                        <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
                        <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
                        <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
                        <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
                        <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
                        <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
                        <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
                        <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
                        <button class="btn btn-primary" type="submit">Print pdf report</button>
                    </form>
                    <form class="form-inline"action="../reports/csv/employees" method="GET">
                        <input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
                        <input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
                        <input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
                        <input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
                        <input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
                        <input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
                        <input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
                        <input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
                        <input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
                        <input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
                        <button class="btn btn-primary" type="submit">Print csv report</button>
                    </form>
                </div>
                <script src="" async defer></script>
    </body>
    
    </html>
    看到它ijn全屏

    【讨论】:

      猜你喜欢
      • 2014-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      • 1970-01-01
      • 1970-01-01
      • 2016-10-28
      • 2021-03-09
      相关资源
      最近更新 更多