The issue of pseudo elements not functioning properly within a Bootstrap Modal component

I have been attempting to apply a specific style to a table within a Bootstrap Modal, but I am encountering issues with highlighting the column and row. Oddly enough, when I include the table in the body of an HTML file, it functions correctly. Can anyone provide some insight into what might be causing this problem?

Style.css

.custom-table-matrix-table {
    border: solid 1px #DDEEEE;
    border-collapse: collapse;
    border-spacing: 0;
}

.custom-table-matrix-table thead th {
    font-size: 12px;
    background: #000000;
    color: #ffffff;
    text-align: center;
}
.custom-table-matrix-table tbody td {
    border: solid 1px #DDEEEE;
    color: #ffffff;
    padding: 10px;
}


.custom-table-matrix-highlight {
    overflow: hidden;
    z-index: 1;
}
.custom-table-matrix-highlight tbody td, .custom-table-matrix-highlight thead th {
    position: relative;
}
.custom-table-matrix-highlight tbody td:hover::before {
    background-color: #CCE7E7!important;
    content:'\00a0'!important;
    height: 100%!important;
    left: -5000px!important;
    position: absolute!important;
    top: 0!important;
    width: 10000px!important;
    z-index: -1!important;
}
.custom-table-matrix-highlight tbody td:hover::after {
    background-color: #CCE7E7!important;
    content:'\00a0'!important;
    height: 10000px!important;
    left: 0!important;
    position: absolute!important;
    top: -5000px!important;
    width: 100%!important;
    z-index: -1!important;
}

Modal code section

  <!-- Modal content-->
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h4 class="modal-title">Modal Header</h4>
    </div>
    <div class="modal-body">
      <p>Some text in the modal.</p>
      <table class="custom-table-matrix-highlight custom-table-matrix-table">
      <thead>
        <tr>
            <th>Week1</th>
            <th>Week1</th>
            <th>Week1</th>
            <th>Week1</th>
        </tr>
      </thead>
      <tbody>
        <tr>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        </tr>
        <tr>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        </tr>
        <tr>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        </tr>
        <tr>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        </tr>
        <tr>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        <td>25.00$</td>
        </tr>
      </tbody>
      </table>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
  </div>

</div>

Answer №1

The issue arises when the styles for pseudo elements are applied only to a particular class that belongs to the table outside of the modal.

For an improved version, check out the revised demo https://jsfiddle.net/ydktv3qc/1/

Answer №2

Instead of placing the class attribute within the div element in the Model section, it should be defined inside the table element.

Make sure to incorporate the model body within the table element as follows:

<table class="modal-body custom-table-matrix-highlight custom-table-matrix-table">

This adjustment should resolve the issue.

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

When a menu is opened or closed in iOS, the HTML content magnifies and shrinks

Currently, I am developing a mobile website featuring a menu similar to that of Facebook. Everything seems to be running smoothly, except for one hiccup on mobile Safari. The issue arises when I open the menu on my iPhone - the remaining content shrinks to ...

On initial loading, Materialize JS seems to experience technical difficulties

Struggling to develop a Vue.js SPA chat application, encountering issues with Materialize CSS and JS. The JS doesn't function properly on initial load and requires a page reload to work. No errors are appearing in the console, making it challenging to ...

The html carousel displays stacked images instead of scrolling

I have been staring at this code for what feels like an eternity, trying to figure out why it's only displaying stacked pictures instead of a functioning carousel. Perhaps I overlooked something crucial. Could someone please lend a hand? My code is pr ...

Design HTML dropdown menu

I have a sleek menu design with rounded buttons, and I am looking to extend the same style to the dropdown list. I have experimented with various approaches but there are two specific issues that I need assistance with: 1. Achieving rounded corners simil ...

JavaScript/jquery loop with an increasing index each iteration

I am currently working with a JSON file that contains paths to various images. I want to regularly add more image paths to this file and display them on an HTML page. However, I am encountering an issue when using the $.each method - the index remains the ...

How can I pass a URL into the <img> tag using WebAPI to load an image encoded in base64 format?

Is there a way to insert a URL from Webapi into an <img> tag? My approach involves converting the image to a base64 string and storing it in the Database as a varbinary. <img src="https://localhost:44381/api/Account/get-resource-image;data:imag ...

Concealing two div elements based on string content

I am working on a unique Wordpress blog post layout that showcases personnel profile cards, displaying 12 individuals at a time. Depending on whether or not a person has a Twitter handle entered in the backend, certain elements should either be shown or hi ...

CSS <ul> <li> spacing issue in Internet Explorer 7

My CSS <ul> <li> nested menu is functioning perfectly in IE 8 and Firefox, but in IE7 it is creating a small gap between the elements. Here is my CSS: #nav, #nav ul { margin: 0; padding: 0; list-style-type: none; list-style-po ...

Tips for retrieving the distance from the top of a specific div element and transferring it to another div

How can I add margin-top based on the tab that is clicked? Specifically, when TAB 4 is selected, I want the content to remain in the same position from the top. https://i.sstatic.net/ObDUg.jpg ...

Scrolling vertically on android using Phonegap

Currently, I am working with a dynamic list on PhoneGap. Is there a way to implement a vertical scroller for a basic ul and li list? I attempted applying overflow:auto to the div, but even though the scroller is visible, it does not work as expected. I p ...

Personalize the style of ordered lists

Greetings! I am attempting to customize the style of an ordered list like the one shown in the image on another website. https://i.sstatic.net/BQok4.png However, instead of the circle used in that picture, I want to use a different CSS Image like the one ...

Is there a way to continually repeat a hover effect?

Currently, I am focusing on creating a timeline and have managed to get the basic function working in jQuery. You can view my progress on jsFiddle here: http://jsfiddle.net/Jason1975/6nwkd2c8/38/ The issue I am facing is that I cannot get the hover effect ...

`The side panel staying fixed at the top of the webpage and not the edge of the monitor.`

I recently started my journey in web development and am currently working on a portfolio website using django and bootstrap 5.3.3. I am facing an issue with my sidebar not sticking to the top of the user's screen, but rather just the page itself. I wa ...

"Troubleshooting: Why is the JavaScript canvas.toDataURL method returning an

While I know this question has been asked multiple times before, I still haven't been able to find a solution. My goal is to take an image, rotate it, and place it in an HTML canvas. To achieve this, I am utilizing another canvas where I rotate the i ...

Running JavaScript code on a webpage using Selenium

I'm currently developing an automated script to enter a person's address details on a webpage. It's important to note that I did not create this webpage myself. While filling in the address details, I encountered an option to select the coun ...

The JQuery CSS function is unable to alter the height of the element

I am working with a grid that contains various elements, each with the class item. When I click on one of these elements, I toggle the class expand to resize the element. <body> <div class="grid"> <a href="#"> < ...

Effortless conversion of ArrayList into user-friendly HTML

Is there a way to format an arraylist into a readable html or text file? I've been struggling with this and can't seem to figure it out. Here's the scenario: I have a log file that keeps track of player eliminations in a game, as shown in th ...

Creating a button that seamlessly adapts to all browsers

I am encountering an issue with the positioning of a chat button on my website. Despite my efforts, the button does not remain in the desired location across different browsers and screen resolutions. The browser zoom also causes inconsistencies in the but ...

The custom icon font sourced from Flaticon and hosted on a separate server is not functioning properly

I recently obtained a unique icon font from Flaticon and decided to incorporate it into a SaaS online store. Since I don't have direct access to the shop's files, I attempted to host the font on an FTP server and integrate it on a demo page: here ...

When my screen measures 1700px wide, a width of 100% in CSS appears significantly narrower than a width of 500px

Currently, I am working on designing a responsive layout for a 3D globe. The code snippet that stores the structure is as follows: <div class="text-center main"> <canvas id='globe' width='100%' height='100%'> ...