我尝试过将缩进和放置放在不同的位置,但是它仍然显示在导航按钮的下方。我希望它在顶部的同一行上。
我试图将它放在同一行上可能有点混乱,如果需要的话,只要在不需要的时候就取出即可。
`

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Bootstrap For Beginners</title>
    <meta name="description" content="Hello World">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

<style>
    .nav {

    }
    .nav container-fluid {


    }
    .nav li {
        display: inline;
        padding: 20px;
        font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
    }

    .jumbotron {


    }
    .jumbotron container-fluid {

    }
    .jumbotron h1 {

    .footer {

    }
    .footer container-fluid {

    }
    .footer p {

    }

</style>

</head>

<body>
    <div class="nav">
        <div class="container-fluid">
            <ul class="nav nav-pills">
                <li class="pull-right"><a href="#">Contact</a></li>
                <li class="pull-right"><a href="#">About</a></li>
            </ul>

            <form class="form-horizontal">
                <div class="form-group">
                    <div class="col-md-6">
                        <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?">
                    </div>
                    <div class="col-md-4">
                        <button type="submit" class="btn btn-default">Submit Feedback</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="jumbotron">
        <div class="container-fluid">
            <div class="row">
                <h1>Student</h1>
                <h1>Business</h1>
            </div>
        </div>
    </div>

    <div class="footer">
        <div class="container-fluid">
            <p>By:</p>
            <p>For:</p>
        </div>
    </div>

    <!-- Latest compiled and minified JavaScript -->
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</body>
</html>


输入栏在很小的窗口上似乎没有响应,这正常吗?

我还希望页脚的大小与导航头的大小相同,并且超大屏幕可以填满两者之间的其余空间,所有内容均适合窗口且无滚动。

提前致谢。

最佳答案

您的代码看起来很棒,您所要做的就是将表单和导航文件包装在包装器/容器中,然后使用col-md-6分隔各节。我在http://www.bootply.com/P7VmPZOfXp为您建立了一个示例。

/* CSS used here will be applied after bootstrap.css */
.footer {
    height: 58px;
    background: #ccc;

  }
<div class="wrapper">
  <div class="container">
    <div class="row">
      <div class="container-fluid">

                    <div class="col-md-6 col-lg-6">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <div class="col-md-6">
                                            <input class="form-control" id="exampleInputEmail2" placeholder="Have Feedback?" type="email">
                                        </div>
                                        <div class="col-md-4">
                                            <button type="submit" class="btn btn-default">Submit Feedback</button>
                                        </div>
                                    </div>
                                </form><!-- .form-horizontal -->
                    </div><!-- .col-6 -->

                      <div class="col-md-6 col-lg-6">
                            <div class="nav">
                                <ul class="nav nav-pills">
                                    <li class="pull-right"><a href="#">Contact</a></li>
                                    <li class="pull-right"><a href="#">About</a></li>
                                </ul>
                            </div><!-- .nav -->
                        </div><!-- .col-6 -->

        </div><!-- .fluid container -->
    </div><!-- .row -->
</div><!-- .container-->
</div><!-- .wrapper-->
    <div class="jumbotron">
        <div class="container-fluid">
            <div class="row">
                <h1>Student</h1>
                <h1>Business</h1>
            </div>
        </div>
    </div><!-- .jumbotron -->

    <div class="footer">
        <div class="container-fluid">
            <p>By:</p>
            <p>For:</p>
        </div>
    </div><!-- .footer -->

关于css - 如何使表格与导航按钮在同一行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28097590/

10-11 22:11
查看更多