Customizing Bootstraps Table Row Color Schemes

I am a novice with Bootstrap and exploring ways to customize the default table colors, specifically the rows. I want to change the color to a solid one without modifying the original Bootstrap CSS file. Despite trying to override it with a new class, Bootstrap continues to display the default colors. I am currently working with Odoo version 8, but I don't think that should impact my ability to make these changes.

Here is the code for my table:

<table class="table">
            <thead>
                <tr class="filters">
                    <th><input type="text" class="form-control" placeholder="#" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="First Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Last Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Username" disabled=""></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>Mark</td>
                    <td>Otto</td>
                    <td>@mdo</td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Jacob</td>
                    <td>Thornton</td>
                    <td>@fat</td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>Larry</td>
                    <td>the Bird</td>
                    <td>@twitter</td>
                </tr>
            </tbody>
        </table>

After examining the Bootstrap CSS, it seems like this is the specific code responsible for styling tables in my case:

}
.table > thead > tr > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: top;
  border-top: 1px solid #000;
}

Answer №1

Despite your attempts to add a custom class and override the CSS without success, I have successfully implemented it by incorporating my own .custom class and then overriding with CSS using

.table.custom > thead > tr > td {}

.table.custom > thead > tr > th,
  .table.custom > tbody > tr > th,
  .table.custom > tfoot > tr > th,
  .table.custom > thead > tr > td,
  .table.custom > tbody > tr > td,
  .table.custom > tfoot > tr > td {
    background-color: red;
    border-top: 4px solid #fff;
}
//for custom table row

.table.custom tr {
      background-color: red;
      border-top: 4px solid #fff;
    }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<table class="table custom">
            <thead>
                <tr class="filters">
                    <th><input type="text" class="form-control" placeholder="#" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="First Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Last Name" disabled=""></th>
                    <th><input type="text" class="form-control" placeholder="Username" disabled=""></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>Mark</td>
                    <td>Otto</td>
                    <td>@mdo</td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Jacob</td>
                    <td>Thornton</td>
                    <td>@fat</td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>Larry</td>
                    <td>the Bird</td>
                    <td>@twitter</td>
                </tr>
            </tbody>
        </table>

Please note that some customization may be required to achieve the desired look, but this serves as a demonstration of the concept.

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

Angular Material - Data Table Kit

Struggling with setting custom styling for a mat-table in Angular Material. I want to adjust the border radius of the table and change the spacing inside to "space-between". The design I'm aiming for is shown here: Design Any tips or suggestions woul ...

Discovering the base color using a hexadecimal color value in C#

When working with a Hex color code in C#, how can you determine if the color falls under the categories of Red, Green, Yellow, Pink, Orange, or Blue? ...

Having trouble rendering the response text from the API fetched in Next.js on a webpage

I've written some code to back up a session border controller (SBC) and it seems to be working well based on the output from console.log. The issue I'm facing is that the response comes in as a text/ini file object and I'm unable to display ...

Refreshed page causing hide/show div to reset

Hello there, I'm currently working on a web application and I need to implement some JavaScript code. The application consists of three sections, each with its own title and button. When the button is clicked, a hidden div tag is displayed. Clicking t ...

Issue encountered while attempting to implement custom fonts through CSS

When attempting to implement a custom font on my website using the CSS file, I am having trouble getting it to display correctly. Instead of seeing the desired font, only the default font is showing up. Can someone please review the CSS code below and le ...

Switching Mouse Hover Effect with a Click: A Quick Guide

I am looking to create a unique effect where the color of an element changes on hover, but the hover effect is disabled while clicking on the element and the clicked element turns red. Once the element is clicked, I want to re-enable the hover effect and a ...

unable to respond when clicking an angularjs link

I'm facing an issue where I can't get a link to respond to click events in AngularJS. When I click on the anchor link, nothing happens. Here is a snippet of the AngularJS script: <script data-require="<a href="/cdn-cgi/l/email-protection" ...

Display a particular div upon clicking a specific link, while concealing the other divs

As a beginner in the world of jQuery and coding, I'm encountering some difficulties that I need help with. My goal is to have the 'Vlogging' link activated and show 'Details 1' when the page loads. Then, upon clicking on either &a ...

Utilizing jQuery to attach events to dynamically inserted elements in the DOM

I am having an issue with dynamically adding elements to the DOM and then trying to manipulate their behavior using jQuery's .on() function. However, for some reason, the DOM is not triggering the .on() event for these dynamically added elements. You ...

Remove elements from an array based on the indices provided in a separate array

1) Define the array a = [a,b,c,d,e,f,g,h,i,j]; using JavaScript. 2) Input an array 'b' containing 5 numbers using html tags. This will be referred to as the 'b' array. 3) Insert elements into array 'b' ensuring they are alwa ...

Two scrollbars within Bootstrap-4 modal

$("div[id^='entry']").each(function(){ var currentModal = $(this); //click next currentModal.find('.btn-next').click(function(){ currentModal.modal('hide'); currentModal.closest("div[id^='entry'] ...

Javascript use of overlaying dynamically generated Canvases

Currently, I am developing a game to enhance my skills in HTML5 and Javascript. In the beginning, I had static canvases in the HTML body but found it difficult to manage passing them around to different objects. It is much easier for me now to allow each ...

Is there a way to incorporate a background image fadeIn effect for ul using CSS3?

I have a list on my webpage where each item is displayed with a CSS3 rotate animation. After the animation finishes, I want to set a background image with a FadeIn effect. To achieve this, I created a "addbg" class for the ul element like so: ul.addbg{ ...

Is it possible to apply a CSS transform without erasing the existing transform?

Looking for a solution: elem transform translateY(5px) scale(1.2) I want the element to move down an extra 5px on hover elem:hover transform translateY(5px) Is there a way to achieve this without knowing the previous state of the transform? Appr ...

Multi-tier Dropdown with Dynamic Size Adjustment

I am attempting to adjust the size of a div container within a dropdown menu so that it properly accommodates the text inside. <div class='dropdown'> <button class ="dropbtn"><b>Hover!</b></button> <div c ...

Tips for controlling the placement of divs on a webpage

I need to align 3 divs in a specific way on my webpage. One should be on the left side taking up 25% of the window, one on the right side also taking up 25%, and the last one in the center taking up the remaining space. I'm struggling with how to achi ...

Balanced arrangement of components

As I work on my first electron app, I've created the initial layout. My goal is to have elements resize when the user adjusts the window size: The red part should change in both width and height The blue part should only adjust in height, not width ...

Guide to adding a new Vue-Grid-Item with a button

Currently, I am working on a software project for the Research department at my university, specifically focusing on an Atomic Layer Deposition system. The main goal of this program is to allow users to create and customize their own 'recipe' for ...

Creating a Custom "Save As" Dialog in HTML5 and JavaScript for Downloading Files

I have developed a NodeJS/Express application that is capable of generating and downloading an Excel document (created using ExcelJS) when a user clicks on a button. Currently, the file gets automatically downloaded to the default download location of the ...

Is it possible to swap out images using srcset attribute?

Currently, I am facing an issue regarding changing the img on mobile and tablet devices to display different images. As a beginner with jQuery, I couldn't resolve it using that framework, so I am exploring options with html5. I am wondering if there ...