How to move tfoot at top?












1















I have a table as follows:



enter image description here



As you can see there are some search input fields with every columns at the bottom. I want to move it top. i.e: just immediate after the <thead> </thead>.



HTML code (basic structure of table, only 2 rows is considered to share here) is:



<table class="table table-striped table-hover" id="sample_5">
<thead>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 4.0
</td>
<td>
Win 95+
</td>
<td>
4
</td>
<td>
X
</td>
</tr>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 5.0
</td>
<td>
Win 95+
</td>
<td>
5
</td>
<td>
C
</td>
</tr>
</tbody>
</table>


First I try to create a room below of thead as follows:



table.dataTable {
margin-top: 84px !important;
position: relative;
}
thead {
position: absolute;
top: -89px;
display: table-header-group;
}


Room is created as I was expecting but width of every thead cell has been changed as following picture:
enter image description here



Any idea?










share|improve this question

























  • Why don't you simply rename tfoot as another thead?

    – Maciej Kwas
    Nov 27 '18 at 15:49
















1















I have a table as follows:



enter image description here



As you can see there are some search input fields with every columns at the bottom. I want to move it top. i.e: just immediate after the <thead> </thead>.



HTML code (basic structure of table, only 2 rows is considered to share here) is:



<table class="table table-striped table-hover" id="sample_5">
<thead>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 4.0
</td>
<td>
Win 95+
</td>
<td>
4
</td>
<td>
X
</td>
</tr>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 5.0
</td>
<td>
Win 95+
</td>
<td>
5
</td>
<td>
C
</td>
</tr>
</tbody>
</table>


First I try to create a room below of thead as follows:



table.dataTable {
margin-top: 84px !important;
position: relative;
}
thead {
position: absolute;
top: -89px;
display: table-header-group;
}


Room is created as I was expecting but width of every thead cell has been changed as following picture:
enter image description here



Any idea?










share|improve this question

























  • Why don't you simply rename tfoot as another thead?

    – Maciej Kwas
    Nov 27 '18 at 15:49














1












1








1








I have a table as follows:



enter image description here



As you can see there are some search input fields with every columns at the bottom. I want to move it top. i.e: just immediate after the <thead> </thead>.



HTML code (basic structure of table, only 2 rows is considered to share here) is:



<table class="table table-striped table-hover" id="sample_5">
<thead>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 4.0
</td>
<td>
Win 95+
</td>
<td>
4
</td>
<td>
X
</td>
</tr>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 5.0
</td>
<td>
Win 95+
</td>
<td>
5
</td>
<td>
C
</td>
</tr>
</tbody>
</table>


First I try to create a room below of thead as follows:



table.dataTable {
margin-top: 84px !important;
position: relative;
}
thead {
position: absolute;
top: -89px;
display: table-header-group;
}


Room is created as I was expecting but width of every thead cell has been changed as following picture:
enter image description here



Any idea?










share|improve this question
















I have a table as follows:



enter image description here



As you can see there are some search input fields with every columns at the bottom. I want to move it top. i.e: just immediate after the <thead> </thead>.



HTML code (basic structure of table, only 2 rows is considered to share here) is:



<table class="table table-striped table-hover" id="sample_5">
<thead>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Rendering engine
</th>
<th>
Browser
</th>
<th>
Platform(s)
</th>
<th>
Engine version
</th>
<th>
CSS grade
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 4.0
</td>
<td>
Win 95+
</td>
<td>
4
</td>
<td>
X
</td>
</tr>
<tr>
<td>
Trident
</td>
<td>
Internet Explorer 5.0
</td>
<td>
Win 95+
</td>
<td>
5
</td>
<td>
C
</td>
</tr>
</tbody>
</table>


First I try to create a room below of thead as follows:



table.dataTable {
margin-top: 84px !important;
position: relative;
}
thead {
position: absolute;
top: -89px;
display: table-header-group;
}


Room is created as I was expecting but width of every thead cell has been changed as following picture:
enter image description here



Any idea?







html css html-table






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 12:30









Brian Tompsett - 汤莱恩

4,2331338101




4,2331338101










asked Nov 27 '18 at 10:19









Abdus Sattar BhuiyanAbdus Sattar Bhuiyan

1,60821539




1,60821539













  • Why don't you simply rename tfoot as another thead?

    – Maciej Kwas
    Nov 27 '18 at 15:49



















  • Why don't you simply rename tfoot as another thead?

    – Maciej Kwas
    Nov 27 '18 at 15:49

















Why don't you simply rename tfoot as another thead?

– Maciej Kwas
Nov 27 '18 at 15:49





Why don't you simply rename tfoot as another thead?

– Maciej Kwas
Nov 27 '18 at 15:49












3 Answers
3






active

oldest

votes


















1














I wouldn't try to hack natural behaviour, for many reasons. Instead I would just make another thead block, with a structure like such:



table
| thead
| tr...
| thead
| tr...
| tbody
| tr...





share|improve this answer































    0














    $('table tfoot').each(function () {
    $(this).insertAfter($(this).siblings('thead'));
    });





    share|improve this answer



















    • 1





      Could you add an explanation as to why that code answers the question?

      – RMcLeod
      Nov 27 '18 at 15:36



















    0

















    $('tfoot').each(function () {
    $(this).insertAfter($(this).siblings('thead'));
    });

    tfoot {
    display: table-row-group;
    }

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <table border="1">
    <thead>
    <tr><td>serial</td><td>head</td></tr>
    </thead>
    <tbody>
    <tr><td>1</td><td>100</td></tr>
    <tr><td>2</td><td>20</td></tr>
    <tr><td>3</td><td>300</td></tr>
    <tr><td>4</td><td>800</td></tr>
    <tr><td>5</td><td>100</td></tr>
    </tbody>
    <tfoot>
    <tr><td>Total</td><td>2000</td></tr>
    </tfoot>
    </table>








    share|improve this answer
























    • Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

      – Abdus Sattar Bhuiyan
      Dec 11 '18 at 6:12











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53497424%2fhow-to-move-tfoot-at-top%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I wouldn't try to hack natural behaviour, for many reasons. Instead I would just make another thead block, with a structure like such:



    table
    | thead
    | tr...
    | thead
    | tr...
    | tbody
    | tr...





    share|improve this answer




























      1














      I wouldn't try to hack natural behaviour, for many reasons. Instead I would just make another thead block, with a structure like such:



      table
      | thead
      | tr...
      | thead
      | tr...
      | tbody
      | tr...





      share|improve this answer


























        1












        1








        1







        I wouldn't try to hack natural behaviour, for many reasons. Instead I would just make another thead block, with a structure like such:



        table
        | thead
        | tr...
        | thead
        | tr...
        | tbody
        | tr...





        share|improve this answer













        I wouldn't try to hack natural behaviour, for many reasons. Instead I would just make another thead block, with a structure like such:



        table
        | thead
        | tr...
        | thead
        | tr...
        | tbody
        | tr...






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 16:00









        Maciej KwasMaciej Kwas

        2,74111333




        2,74111333

























            0














            $('table tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });





            share|improve this answer



















            • 1





              Could you add an explanation as to why that code answers the question?

              – RMcLeod
              Nov 27 '18 at 15:36
















            0














            $('table tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });





            share|improve this answer



















            • 1





              Could you add an explanation as to why that code answers the question?

              – RMcLeod
              Nov 27 '18 at 15:36














            0












            0








            0







            $('table tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });





            share|improve this answer













            $('table tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 27 '18 at 10:37









            Hasan TareqHasan Tareq

            65111




            65111








            • 1





              Could you add an explanation as to why that code answers the question?

              – RMcLeod
              Nov 27 '18 at 15:36














            • 1





              Could you add an explanation as to why that code answers the question?

              – RMcLeod
              Nov 27 '18 at 15:36








            1




            1





            Could you add an explanation as to why that code answers the question?

            – RMcLeod
            Nov 27 '18 at 15:36





            Could you add an explanation as to why that code answers the question?

            – RMcLeod
            Nov 27 '18 at 15:36











            0

















            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>








            share|improve this answer
























            • Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

              – Abdus Sattar Bhuiyan
              Dec 11 '18 at 6:12
















            0

















            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>








            share|improve this answer
























            • Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

              – Abdus Sattar Bhuiyan
              Dec 11 '18 at 6:12














            0












            0








            0










            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>








            share|improve this answer
















            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>








            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>





            $('tfoot').each(function () {
            $(this).insertAfter($(this).siblings('thead'));
            });

            tfoot {
            display: table-row-group;
            }

            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <table border="1">
            <thead>
            <tr><td>serial</td><td>head</td></tr>
            </thead>
            <tbody>
            <tr><td>1</td><td>100</td></tr>
            <tr><td>2</td><td>20</td></tr>
            <tr><td>3</td><td>300</td></tr>
            <tr><td>4</td><td>800</td></tr>
            <tr><td>5</td><td>100</td></tr>
            </tbody>
            <tfoot>
            <tr><td>Total</td><td>2000</td></tr>
            </tfoot>
            </table>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 27 '18 at 10:56









            Hasan TareqHasan Tareq

            65111




            65111













            • Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

              – Abdus Sattar Bhuiyan
              Dec 11 '18 at 6:12



















            • Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

              – Abdus Sattar Bhuiyan
              Dec 11 '18 at 6:12

















            Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

            – Abdus Sattar Bhuiyan
            Dec 11 '18 at 6:12





            Thanks for your time. in bootstrap table it does not change view based on physical place of <tfoot>. Meaning when I inspect <tfoot> is move immediate after the <thead> but the render table places tfoot at footer. I resolved this issue with an tricks (taking another table for my purpose).

            – Abdus Sattar Bhuiyan
            Dec 11 '18 at 6:12


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53497424%2fhow-to-move-tfoot-at-top%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks