Bootstrap响应表消失

时间:2017-06-21 10:08:10

标签: html css twitter-bootstrap

我正在尝试做一个响应表,但我的表在宽大的窗口中消失,我无法理解为什么。我的代码在这里,响应的行表被评论,所以它在宽屏幕上工作,我可以看到表格:

<delimiters>
  <delimiter>${*}</delimiter>
  <delimiter>@</delimiter>
</delimiters>

CSS

    <!DOCKTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
            <title>WebHosting-Preços</title>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
            <link rel="stylesheet" href="main.css" type="text/css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        </head>
        <body>
            <!--NavBar-->
            <div class="row">
                <div class="col-lg-8">
                    <nav class="navbar navbar-inverse navbar-fixed-top">
                        <div class="container-fluid">
                            <div class="navbar-header">
                                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                </button>
                                <a class="navbar-brand" href="index.html">WebHosting</a>
                            </div>
                            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                                <ul class="nav navbar-nav navbar-right">
                                    <li><a href="contactos.html">Contactos</a></li>
                                    <li><a href="preços.html">Preços</a></li>
                                </ul>
                            </div>
                        </div>
                    </nav>
                </div>
            </div><!--NavBar END-->
            <div class="columns2">
                <ul class="price">
                    <li class="header">Host</li>
                    <li class="grey">Free</li>
                    <li>Sem criação de WebSite</li>
                    <li>Sem Dominio</li>
                    <li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
                </ul>
            </div>
            <div class="columns2">
                <ul class="price">
                    <li class="header">Host + WebSite</li>
                    <li class="grey">€ 9.99</li>
                    <li>Criação do WebSite</li>
                    <li>Sem Dominio</li>
                    <li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
                </ul>
            </div>
            <div class="columns2">
                <ul class="price">
                    <li class="header">Host + WebSite + Dominio</li>
                    <li class="grey">€ 9.99 / year</li>
                    <li>Criação do WebSite</li>
                    <li>Dominio incluido</li>
                    <li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
                </ul>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered">
                    <tr>
                        <th>Serviço</th>
                        <th>Descrição</th>
                    </tr>
                    <tr>
                        <td>Criação de website</td>
                        <td>A Empresa responsabiliza-se pela criação de um website a seu gosto</td>
                    </tr>
                    <tr>
                        <td>Dominio</td>
                        <td>A Empresa responsabiliza-se pela compra e manutenção do Dominio escolhido pelo utilizador</td>
                    </tr>
                </table>
            </div>
        </body>
    </html>

3 个答案:

答案 0 :(得分:1)

它可能会有所帮助。

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="container">
  <h2>Table</h2>
  <p>The .table-responsive class creates a responsive table which will scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, there is no difference:</p>                                                                                      
  <div class="table-responsive">          
  <table class="table">
    <thead>
      <tr>
        <th>#</th>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
        <th>City</th>
        <th>Country</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>1</td>
        <td>Anna</td>
        <td>Pitt</td>
        <td>35</td>
        <td>New York</td>
        <td>USA</td>
      </tr>
    </tbody>
  </table>
  </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

可能是.table-responsive类继承或覆盖你的css或任何其他css /库覆盖它。

但我尝试使用表格响应类下面的示例,它工作正常。

&#13;
&#13;
<!DOCTYPE html>
<html>
<head>
  <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">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
                                                                            
  <div class="table-responsive">          
  <table class="table">
    <thead>
      <tr>
        <th>#</th>
        <th>Column 1</th>
        <th>Column 2</th>
        <th>Column 3</th>
        <th>Column 4</th>
        <th>Column 5</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>test1</td>
        <td>test2</td>
        <td>test3</td>
        <td>324</td>
        <td>123</td>
        <td>000</td>
      </tr>
    </tbody>
  </table>
  </div>
</div>

</body>
</html>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

问题在于这一部分:

<div class="container">                                                                                 
    <div class="table-responsive">          
        <table class="table">
            <thead>
                <tr>
                    <th>Serviços</th>
                    <th>Descrição</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>test1</td>
                    <td>test2</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

它只表示响应表而不是普通表和响应表,为了改变它,我需要这样做:

<div class="table table-responsive">

而不是

<div class="table-responsive">