Skip to main content
Inspiring
November 11, 2020
Answered

Bootstrap causes display problems

  • November 11, 2020
  • 3 replies
  • 1047 views

I had a web page that worked fine. Then I added a table. The table displayed fine in Dreamweaver Design mode, but in Live mode the cell spacing was missing. Also horizontal rules did not display. The same display problems existed in a browser.

 

I slowly deleted parts of my page and while I found that deleting the dropdown menu did not solve the problem, deleting the three lines of code needed for bootstrap implementation of dropdown menu did solve the cell spacing and horizontal rule problem.

 

The lines deleted from the "head" were:

 

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

 

This is the first time I had used bootstrap. I used it because it appeared that the very old method I had used in the past to create dropdown menus was obsolete.

 

Why do these lines of code cause the table to display incorrectly and the horizontal rule not to display at all?

 

What should I do to implement a dropdown menu and still get the table and horizontal rule to display correctly?

 

Thank you for your help.

    This topic has been closed for replies.
    Correct answer osgood_

    And yes, I will read about using bootstrap tables. Sounds like a good idea, but I still want to get what I have working first.


    Firstly you should NOT/NEVER be using Bootstrap v3 on a new build website, that verison is years old and outdated. The current stable version is v4 and there is a v5 version which has just recently been released and is fairly stable I believe.

     

    To answer your sepecific questions -

     

    By default Bootstrap v3 and v4 will removed the default spacing in ALL table cells.

     

    Bootstrap v4 does it with the following css selector:

     

    table {
    border-collapse: collapse;
    }

     

    Bootstrap v3 (currently the version you are using) removes the <hr> tag completley from view by setting the height to 0, whilst Bootstrap v4 retains the <hr> tag but sets its default color to gray with the following css selector:

     

    hr {
    margin-top: 1rem;
    margin-bottom: 1rem;
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    }

     

    You can change the color of the <hr> tag (if you are using Bootstrap v4) by over-riding the css in a dedicated stylesheet (DO NOT ever alter the default Bootstrap css file):

     

    hr {
    border-top: 1px solid red!important;
    }

     

    To re-instate the table cell spacing you are meant to use the built in Bootstrap helper classes:

     

    In your particular table case and using Bootstrap v4 you would add some vertical cell spacing - class="py-1" as shown below:

     

     

     

    <table width="600" border="0" cellspacing="10" cellpadding="0">
    <tbody>
    <tr>
    <td width="150" class="py-1">nono</td>
    <td width="150">pnm</td>
    <td width="150">pmomi</td>
    <td width="150">i p</td>
    </tr>
    <tr>
    <td width="150" class="py-1">;luyb </td>
    <td width="150"> louo</td>
    <td width="150">'po po </td>
    <td width="150">p o'ip </td>
    </tr>
    <tr>
    <td width="150" class="py-1">on7898b7</td>
    <td width="150">'ooinu</td>
    <td width="150"> op' iop </td>
    <td width="150"> 'po </td>
    </tr>
    </tbody>
    </table>

     

     

     

    Key here is to decide if you are going to use Bootstrap or not and then take advantage of its built in css classes if you do! Take some time out to learn the Bootstrap default helper classes.

     

    Yes, you can certainly mix and match Bootstrap and your own code/css but you need to be aware of how Bootstrap works and how to overide its many css classes.

     

    Personally I think its bloated over complicated junk with over 8000 lines of css unminified, the majority of which you will never ever need, lying there doing nothing, whilst eating up critical load-time, especially on mobile devices. Most 'developers', especially amatuers where the majority of Bootstrap builds are used WILL NEVER optimise the css to deploy just what is needed, which is possible.

     

    Of course its down to the individual to decide their own path - I'm just laying bare some true facts and figures which most Bootstrappers prefer you not to know.

     

    Hope the above helps you in some way, whether you continue with Bootstrap or not.

    3 replies

    Nancy OShea
    Community Expert
    Community Expert
    November 11, 2020

    Hi Marcus,

    For quickest help in this forum, upload your problem page and assets to a TEST folder on your remote server so we can see it.  When your question is resolved, you may delete the TEST folder from your server.

     

    #1 Tables are for tabular data ONLY -- spreadsheets, charts, schedules. 

     

    #2 Tables for layout are counterproductive because they are not responsive.  In other words, tables defeat the whole purpose of using a responsive framework like Bootstrap.  Don't use tables if you can avoid them.

     

    #3 If you're building #1 and absolutely can't avoid a table, use Bootstrap's built-in responsive tables.  But keep in mind that "ease of use" is diminished for users on small handhelds.

    https://getbootstrap.com/docs/4.5/content/tables/

     

    Nancy O'Shea— Product User & Community Expert
    Participating Frequently
    November 12, 2020

    Thank you all for your help. I have constructed a scaled down web page that will illustrate the problem. It is located at:

     

    http://www.backcountryskitours.com/private/test_pages/sample_page.htm

     

    My question remains, why does the use of bootstrap cause the cell spacing and horizontal rules not to display?

     

    Thank you for any help you can provide me.

     

    Marcus Libkind

    Participating Frequently
    November 12, 2020

    And yes, I will read about using bootstrap tables. Sounds like a good idea, but I still want to get what I have working first.

    Community Expert
    November 11, 2020

    Deleting parts of code like this sporadically will usually lead to more problems then it resolves.  When trying to troubleshoot these types of issues you should use the inspector in your browser to see what style rules are affecting things like padding, spacing, etc. and then target those rules by editing, or appending, as opposed to deleting.

     

    As already suggested the best thing you can do at this point is share a link, but if you are utilizing bootstrap at all on the page, please add the bootstrap includes back to the page before you share with us.

    Legend
    November 11, 2020

    When using 3rd party solutions like a library i.e. Bootstrap etc there is a possibility that the files used to control the library could conflict with the code you have used which is not related to Bootstrap.

     

    If you can provide a link to the problem page which includes the Bootstrap library someone may be able to provide you with a more difinitive answer as to why this is happening, it may not be related to Bootstrap at all.