Как исправить заголовок таблицы?

0

Как получить заголовок таблицы, фиксированной, когда данные таблицы прокручиваются через jquery! высота фиксированной таблицы

<html>
 <body>
  <style type="text/css">
   <table class="fx">
    <tbody>
      <tr>
       <th>Email ID</th>
       <th>Time Taken to complete game (secs)</th>
       <th>Email ID</th><th>Time Taken to complete game (secs)</th>
      </tr>
    </tbody>
   </table>
 </div>
 <table class="data">
  <tbody>
   <tr>
    <td>[email protected]</td>
    <td>449</td>
    <td>[email protected]</td>
    <td>449</td>
   </tr>
   <tr>
   <tr>
    <td>[email protected]</td>
    <td>449</td><td>[email protected]</td>
    <td>449</td>
   </tr>
   <tr>
    <tr>
     <td>[email protected]</td>
     <td>449</td>
     <td>[email protected]</td>
     <td>449</td>
    </tr>
     <tr> 
   </tr>
  </tbody>
 </table>

    table tbody
    {
       display: block;
    height: 262px;
    overflow: auto;
          }
      table {
    table-layout: fixed;
    height: 100px;
    overflow: auto;
    padding: 10px;
    }
    table tr{
        background-color: #F5F5F5;
    }
    table tr:nth-child(odd){

        background-color: #eee;
    }
    table tr:nth-child(even){

        background-color: #F5F5F5;
    }
    table tr td{
        padding:10px;
        width: 200px; 
         max-width: 200px;
        word-wrap:break-word;
        height: auto;
        text-align: center;
        color:#5d8d5d;
    }
    .fx{
         position: fixed;
      top: 0;

      left: 0;
      }

      .fx tr th {
        padding:10px;
        background-color: #ddd;
        width: 200px;
        color:#6d4d9d;
        text-align: center;

    }

    .data{
      margin-top: 70px;
    }

    div{
      position: relative;

    }
    *{
      margin: 0;
      padding: 0;
    }

    </style>
    <div>



    </body>
    </html>

Как получить заголовок таблицы, фиксированной, когда данные таблицы прокручиваются через jquery! высота стола необходимо срочно

  • 0
    Посмотрите здесь: stackoverflow.com/questions/4709390/…
  • 0
    нужно срочно плохо пахнет , это показывает, что ваш босс собирается вас шлепнуть ... в любом случае, ваша таблица, кажется, имеет фиксированную width поэтому вы можете попробовать это stackoverflow.com/a/17828082/1542290 .. кстати, это PURE CSS
Показать ещё 3 комментария
Теги:

1 ответ

1

Смотрите эту ссылку

ИЛИ

Не могли бы вы попробовать это...

Стиль CSS:

<style>
        table tbody
    {
        display: block;
        height: 262px;
        overflow: auto;
    }
    table
    {
        table-layout: fixed;
        height: 100px;
        overflow: auto;
        padding: 0px;
    }
    table tr
    {
        background-color: #F5F5F5;
    }
    table tr:nth-child(odd)
    {
        background-color: #eee;
    }
    table tr:nth-child(even)
    {
        background-color: #F5F5F5;
    }
    table tr td
    {
        padding: 0px;
        width: 200px;
        max-width: 200px;
        word-wrap: break-word;
        height: auto;
        text-align: center;
        color: #5d8d5d;
    }
    .fx
    {
        position: fixed;
        top: 0;
        left: 0;
       min-width:850px;
       width:850px;
    }

    .fx tr th
    {
        padding: 10px;
        background-color: #ddd;
        width: 175px;
        min-width: 175px;
        color: #6d4d9d;
        text-align: center;
    }

    .data
    {
        margin-top: 0px;
        min-width:850px;
        width:850px;
        left: 0;
    }
    .data tr th
    {
        padding: 10px;
        width: 175px;
        min-width: 175px;
        text-align: center;
    }

    div
    {
        position: relative;
    }
    *
    {
        margin: 0;
        padding: 0;
    }
    </style>

HTML:

<table class="fx">
        <tbody>
            <tr>
                <th>
                    Email ID
                </th>
                <th>
                    Time Taken to complete game (secs)
                </th>
                <th>
                    Email ID
                </th>
                <th>
                    Time Taken to complete game (secs)
                </th>
            </tr>
        </tbody>
    </table>
    <div id="data" style="valign: top; overflow: auto; min-width:850px; height: 100px; margin-top: 60px;
        padding-top: 0px">
        <table class="data">
            <tbody>
                <tr>
                    <th>
                        [email protected]
                    </th>
                    <th>
                        449
                    </th>
                    <th>
                        [email protected]
                    </th>
                    <th>
                        449
                    </th>
                </tr>
                <tr>
                    <tr>
                        <th>
                            [email protected]
                        </th>
                        <th>
                            449
                        </th>
                        <th>
                            [email protected]
                        </th>
                        <th>
                            449
                        </th>
                    </tr>
                    <tr>
                        <tr>
                            <th>
                                [email protected]
                            </th>
                            <th>
                                449
                            </th>
                            <th>
                                [email protected]
                            </th>
                            <th>
                                449
                            </th>
                        </tr>
                        <tr>
                        </tr>
            </tbody>
        </table>
    </div>
  • 0
    @ user3011961 Пожалуйста, дайте мне знать, если он не работает для вас ...
  • 0
    @ user3011961 У вас есть возможность проверить это?
Показать ещё 16 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню