对齐两个表单和其他内联按钮

时间:2018-05-25 20:45:31

标签: twitter-bootstrap-3

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

    <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>

2 个答案:

答案 0 :(得分:0)

  

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

     

NB:

     
      
  1. 表单是块项目 - 通过css或style更改为inline-block。
  2.   
  3. 按钮仍然换行,可能需要将col-xs-6更改为更广泛的
  4.   

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>

答案 1 :(得分:0)

&#13;
&#13;
<!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>
&#13;
&#13;
&#13;  看到它全屏