Code Monkey home page Code Monkey logo

bootstrap4-card-tables's Introduction

Bootstrap4 Card Tables

CSS for properly rendering tables inside of cards in Bootstrap 4

While Bootstrap 3 supported tables inside of panels, tables are not supported in cards (the replacement for panels) in Bootstrap 4. Although the resulting visual glitches can be fixed using several helper classes on the card component and the table itself, this is something that would be nice if it would just work. Thus, this package provides the needed styles to use tables inside of cards in Bootstrap 4 without any additional helper classes. It also modifes the horizontal padding of table cells to match that of the card header, body, and footer.

Installation

npm install --save-dev bootstrap4-card-tables

Usage

Import the SASS source files into your app:

@import "~bootstrap4-card-tables/src/bootstrap4-card-tables";

Compiled (and optionally, minified) CSS is provided in the dist directory:

https://unpkg.com/[email protected]/dist/bootstrap4-card-tables.css
https://unpkg.com/[email protected]/dist/bootstrap4-card-tables.min.css

Notes

  • This package fixes the use cases I encountered when trying to use tables inside of cards in Bootstrap 4, but I do not consider this package to be comprehensive. If you encounter an edge case not covered by this package, feel free to open an issue or submit a pull request.
  • There is currently an open issue and a pull request on the Bootstrap project for adding native support for tables inside of cards to an upcoming release of Bootstrap 4. While progress has been slow, it would be worth checking if there have been any recent developments there before using this package.

Screenshots

Given the markup below, this package fixes the visual glitches without requiring any additional classes to be added to the markup.

Before

before screenshot

After

after screenshot

HTML

<div class="card">
    <div class="card-header">Card Header</div>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
                <th>Column 3</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td>Row 1 Cell 1</td>
                <td>Row 1 Cell 2</td>
                <td>Row 1 Cell 3</td>
            </tr>

            <tr>
                <td>Row 2 Cell 1</td>
                <td>Row 2 Cell 2</td>
                <td>Row 2 Cell 3</td>
            </tr>

            <tr>
                <td>Row 3 Cell 1</td>
                <td>Row 3 Cell 2</td>
                <td>Row 3 Cell 3</td>
            </tr>
        </tbody>
    </table>

    <div class="card-footer">
        Card Footer
    </div>
</div>

bootstrap4-card-tables's People

Contributors

philipnewcomer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.