How can I create a nested table within a Bootstrap table without inheriting the parent "table" class?

I am facing an issue with two nested tables, where the parent table is styled using

class="table table-bordered table-hover"
from Bootstrap. However, the nested table inherits all the styles from the parent, causing conflicts as I need the nested table to have a different appearance without any Bootstrap styling.

Is there a quick and simple way to prevent the nested table from inheriting the CSS properties of the parent table?

(The following code snippet does not directly represent my situation but can serve as a helpful example for us to troubleshoot a solution.)

Thank you!

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">

<table class="table table-bordered table-hover">
  <tr>
    <td>Row 1</td>
  </tr>
  <tr>
    <td>Row 2</td>
  </tr>
  <tr>
    <td>
      <table>
        <tr>
          <td>Nested 1a</td>
          <td>Nested 2a</td>
          <td>Nested 3a</td>
         <tr>
        <tr>
          <td>Nested 1b</td>
          <td>Nested 2b</td>
          <td>Nested 3b</td>
         <tr>
       </table>
    </td>
  </tr>
  <tr>
    <td>Row 3</td>
  </tr>
 </table>

Answer №1

Essentially, the solution to this issue has already been provided here. According to the documentation...

"All table styles are inherited in Bootstrap 4, meaning any nested tables will be styled in the same manner as the parent."

Consequently, one must incorporate some overriding CSS to "reset" the inner table...

.table-plain tbody tr,
.table-plain tbody tr:hover,
.table-plain tbody td {
  background-color:transparent;
  border:none;
}

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

`Generating an ever-changing masonry layout on a website using live data`

I'm currently working on a new web project and I want to incorporate a masonry view for the images on the homepage. The plan is to host this project on Azure, using blob storage for all the images. My idea is to organize the images for the masonry vi ...

Ideas for utilizing jQuery to extract data from CSS files

Hey there, I'm facing an issue on my HTML page where I have jQuery included. In my CSS file, I have quite a lot of lines and I'm trying to figure out how to read all styles for a specific element from the external CSS file rather than the inline ...

Issue with dropdown menu appearing beneath specific elements in Internet Explorer versions 7 and 8

I've been encountering some troublesome issues with a website I'm working on, specifically in Internet Explorer 7/8. On certain pages, the navigation elements are getting hidden below text and images, causing confusion for me. I've attempted ...

How to keep Bootstrap 4 popover open when hovering over it

During my coding journey, I came across this nifty snippet that allowed popovers to stay open on hover: var originalLeave = $.fn.popover.Constructor.prototype.leave; $.fn.popover.Constructor.prototype.leave = function(obj){ var self = obj instanceof thi ...

Click on an image to select four numbers using JavaScript

I have a selection of images representing numbers 1 through 9. When a user clicks on one of these images, I want to save the corresponding number (e.g., if they click on the image with the number 1, I want to save the number 1). However, I only require fou ...

Utilize CSS to ensure footer fills remaining bottom space

My goal is to have the footer take up the entire remaining bottom space. Currently, I am using the following CSS for the footer: clear: both; float: left; background-color: #1F1102; color: #E4F2FA; min-height: 60px; font-family: Verdana, Geneva, sans-serif ...

When a radio button is clicked in Angular7 and it shares the same form control name, both radio buttons are being

Visit this StackBlitz link for more information. places = ['effil tower','new discover'] new FormGroup({place: new FormControl()}); <div *ngIf="places?.length > 0" class="col-12"> <div style=" padding-top: 1e ...

Retrieve values from the same row using JQuery

<tr> <td style="display:none;"> 62 </td> <td> <span style="color:Blue; cursor:pointer;" id="editLink">Edit</span> | ...

Tips for storing HTML form data in a local JSON file without the need for PHP or Node.js dependencies

I'm interested in saving any information panel in an HTML file to a local JSON file. For example, if there are blocks like this: <div class="panel"> <div> <input type="text" name="producttype" id=&q ...

Unable to specifically identify or focus on this offspring

I am attempting to target the class has-translucent-status-bar nested within another class called platform-ios To achieve this, I have used the following code: .platform-ios > .has-translucent-status-bar Unfortunately, this approach has not been succ ...

What steps can be taken to design a form containing only a field for selecting the YEAR?

Can anyone help me create a filter form that only displays the year option? I'm looking to have either a dropdown list or datepicker that exclusively shows the years. I'm new to this so any assistance would be greatly appreciated. I've been ...

jQuery's promise method in CSS is executed successfully

Seeking advice from someone: Scenario: Currently, I have <div id="breadCrumb" style="width:80%"></div> Now, I want to update the width to 100% and retrieve the width in pixels on click $('#menu_toggle').on('click', funct ...

Retrieve the JavaScript blob's file name without including a hyperlink

How can I customize the filename of a blob file in JavaScript when using window.location to force download it? function createCustomFile(data) { var json = JSON.stringify(data); var blob = new Blob([json], {type: "octet/stream"}); var ...

Classes were successfully stored on the icon following the page's refresh

I'm struggling with the following code snippet: <div class="places-item"> <div class="places-item-img"></div> <div class="places-item-header"> <h2>Machu Picchu, Peru</h2> <div cl ...

Show a clear box over an HTML table row upon mouseover, without highlighting the row

I'm looking to implement a transparent box, with a button, that surrounds a table row when the user hovers over it. I've searched on Google but all the pages only talk about how to highlight rows on hover. I am currently using JavaScript to add ...

When you input text into a contenteditable div, it automatically gets placed inside a span element instead of being placed

I'm having an issue with my contenteditable div. Whenever I click the button, a span is inserted into the div. However, when I start typing, the text goes inside the span instead of outside it: jQuery(document).ready(function($) { let input = $(" ...

How to set a canvas as the background of a div element

Check out my code snippet below: <!DOCTYPE html> <html> <body> <div id='rect' style='width:200px;height:200px;border:1px solid red'> </div> <canvas id="myCanvas" style="borde ...

How can I make sure the footer stays at the bottom of the page on shorter pages in my

I am currently working on a website and trying to figure out how to make the footer stick to the bottom of the screen. I attempted a solution from ryanfait but it didn't work with my theme. Another method I tried using absolute positioning placed the ...

Bulma inquired, "What is the best way to position a button at the center of a

<div class="container"> <button class="btn">Click me</button> </div> <button class="is-centered"> seems to be malfunctioning. ...

Keep one div attached to the edge of another div to ensure they remain conjoined when resizing

Is there a way to center a Square within the border of another div? I have attempted the following method: .container { position: relative; background-color: blue; } .square { position: absolute; height: 50px; width: 50px; border-radius: 0% ...