How to achieve striped columns with Bootstrap 4.0 instead of striped rows

Here is how my table currently looks with the implementation in place:

https://i.sstatic.net/b7onC.png

Since my data is displayed vertically, I am interested in adding stripes to the columns or implementing some CSS hovering effect when the mouse is over a column.

This is the code pertaining to the table mentioned above:

<div class="table-responsive">
            <table class="table table-sm table-bordered">
              <thead>
                <tr>
                    <th>
                        Properties
                    </th>
                    <th *ngFor="let row of tableResult?.rows; let i=index" scope="col">
                        Result #{{i+1}}
                    </th>
                </tr>
              </thead>
                <tbody>
                    <tr *ngFor="let column of tableResult?.columns; let cind=index">
                        <th scope="row">{{column}}</th>
                        <td *ngFor="let row of tableResult?.rows">{{row[cind]}}</td>
                    </tr>
                    <tr>
                        <th>More Info.</th>
                        <td scope="row" *ngFor="let uuid of tableResult?.uuids">
                            <button class="btn btn-xs btn-outline-success">
                                More
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

I am uncertain about whether I need to include colgroup to enhance column recognition.

Does Bootstrap offer a class to add stripes to columns? If not, what would be the CSS approach to highlighting them?

Answer №1

Source: CSS Tricks

This code snippet allows for Column Highlighting in a simple way.

/*Column Highlighting*/
table {
    overflow: hidden;
}

td, th {
    position: relative;
}
td:hover::after,
th:hover::after {
    content: "";
    position: absolute;
    background-color: rgba(0,0,0,0.075);
    left: 0;
    top: -5000px;
    height: 10000px;
    width: 100%;
    z-index: -1;
}

It performs effectively.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips to prevent elements from overlapping in Angular applications

I am facing an issue with my Angular-based app where I dynamically populate the page with table rows. There is an app-console element below the page that has a fixed position. Whenever I click the button to add a new row, it overlaps with the app-console. ...

Expandable fluid inline svg that dynamically fills the remaining space alongside text within a flex row

How can I ensure that an inline SVG occupies all available space within a row without specifying its height across different screen sizes? The solution involves setting the SVG to have 100% height with a viewBox, allowing it to adjust accordingly while ma ...

The Bootstrap 4 dropdown seems to have a one-time use limit

I'm currently working on a dropdown menu using Bootstrap 4. The dropdown menu is functional, but I'm facing an issue where it only toggles once. I have tried various solutions recommended on different websites, but none of them seem to work. Belo ...

Real-time Data Stream and Navigation Bar Location

Utilizing the EventSource API, I am pulling data from a MySQL database and showcasing it on a website. Everything is running smoothly as planned, but my goal is to exhibit the data in a fixed height div, with the scrollbar constantly positioned at the bott ...

Are there any tools available that can generate CSS code automatically

Our team offers a pre-set CSS file along with the HTML mock-up for partners to customize, such as changing colors and background images, to match their desired aesthetic. They then provide feedback on the modified CSS files back to us. However, we face a ...

Measuring the space between components

I am looking for a way to dynamically calculate distance on a canvas, similar to the example shown in the figure. I want to be able to drag the highlighted joints in order to adjust the span for calculating distances. Are there any plugins available for th ...

Are chat bubbles compatible with Bootstrap and Flex?

Can someone help me create chat bubbles within the bootstrap framework? I want to have right and left bubbles distinguished by two classes, such as right and left. Each bubble should have a maximum width of 70%, but adjust to be smaller if the text is not ...

The search bar is visible on desktop screens and can be expanded on mobile devices

Check out my code snippet below. <style> #searchformfix { width: 50%; border-right: 1px solid #E5E5E5; border-left: 1px solid #E5E5E5; position: relative; background: #fff; height: 40px; display: inline-block; border: ...

Styling the center menu

Is there a way to horizontally center this top menu using CSS? https://i.sstatic.net/9yvJf.png This is the HTML structure I am working with: <div class="wrapper_menu_hoz"> <div class="container_24 "> <div class="gr ...

Interactive jQuery Dropdown Menu with Multiple Divs

I have been working on this and I'm almost there, but the jQuery part is driving me crazy (I'm not very proficient in it yet, but I am learning). Here's the link to the fiddle: http://jsfiddle.net/5CRA5/4/ Since I can't demonstrate th ...

What is the reason behind Material UI's decision to utilize display flex instead of display grid?

The Grid component implements the grid system. It leverages the Flexbox module in CSS to provide great flexibility. What is the reason behind material UI using display flex instead of display grid? ...

Extend the width of a div element to fit the size of its absolutely positioned

I am facing an issue with a Div that contains multiple absolutely positioned divs. The clickable area of the main div expands to cover the children, but the drawn area does not. I need the drawn area to encompass all the container divs. You can view a JSF ...

Arranging Menu Items in a Horizontal Stack Instead of a Vertical Stack Using v-for in Bootstrap Navbar

Currently utilizing Bootstrap 4 in conjunction with vue.js Router. I have successfully constructed a Bootstrap Navbar: <b-navbar toggleable="lg" type="light" variant="white"> <b-navbar-toggle target="nav-collapse ...

How do you retrieve specific colored elements from an array using jQuery (or plain JavaScript)?

I am currently in the process of creating interactive checklists. One feature I have implemented is changing the color of a header if all checkboxes associated with it are checked, as shown below: $("input[type='checkbox']").click(function(){ i ...

Tips for handling CSS loading delays with icons in OpenLayers markers

When using openlayers (v4.6.4) with font-awesome as marker icons, the icons do not display upon first load (even after clearing cache and hard reload). Instead, I see a rectangle resembling a broken character. It is only on the second load that they appear ...

The minified version of Bootstrap's CSS will only be loaded when I explicitly import it in my index

I used to rely on BootstrapCDN for my styles, but now I want to download the files and use them locally. However, when I try to load the styles without an internet connection, they don't seem to work properly, especially the grid layout. My current s ...

Why is the child's CSS hover not functioning when the body has an event listener attached to it?

Check out the repository link here: https://codepen.io/Jaycethanks/pen/WNJqdWB I am trying to achieve a parallax effect on the body and image container, as well as a scale-up effect on images when hovered over. However, the hover functionality is not work ...

Can you explain the purpose of the URL function in the context of url("#foobar"

Currently, I am developing a CSS concatenator and one of the tasks involved is URL to absolute URL rewriting. For this process, I exclude any absolute URLs that start with http, https, etc. In the case of Django projects, they designate the following URL ...

The jQuery attr() method is universally compatible across platforms and stands independent

I have a jQuery statement that is currently working for me, but I am unsure if it is cross-platform independent. Can anyone confirm? $("input[name='confirmed']").attr("checked",false); It is functioning correctly on the latest version of Firefo ...

Using Array Data Format to Customize Color in Highcharts Funnel Chart

I have included the funnel visualization code that I've been working on. $(function() { var dataEx = [ ['1 Visit', 352000], ['2 Visits', 88000], ['3+ Visits', 42000] ], len = dataEx.length, ...