Styling table cell heights in Internet Explorer using the td pseudo-class

Initially, I was skeptical that this styling would be achievable in Chrome/Firefox, but to my surprise, it worked! However, the same cannot be said for Internet Explorer (typical, right?).

Despite functioning properly in Chrome/Firefox/Safari/Opera, I hoped that it might also work in the latest versions of Internet Explorer, unfortunately, I encountered the same issue from IE11 downwards. I haven't tested it in EDGE yet.

If you want to view the mark-up/CSS, you can check out this CodePen link: http://codepen.io/moy/pen/yewbBx

Basically, I have a standard table with rows where the 'selected' row is slightly wider than the rest. This effect is achieved using the :before pseudo-class for the first and last <td> elements of a selected row, similar to this:

tr.selected td {
    background-color: @brown-lightest;
    position: relative;
}

tr.selected td:first-child:before,
tr.selected td:last-child:before {
    background: @brown-lightest;
    content: "";
    display: block;
    height: 100%;
    position: absolute;
    left: -5px;
    top: 0;
    width: 5px;
}

tr.selected td:last-child:before  {
    left: auto;
    right: -5px;
}

Sometimes it appears to be working fine, but it seems like both the first and last <td> must have the same height for it to work correctly. Even though td:before {height: 100%;} is specified, it seems to take the height of the text rather than the <td>. It's puzzling since in a table layout, all row heights should be consistent, right?

I realize that this might not be achievable in IE, but I wanted to explore if anyone has any insights as to why this issue may be occurring, just in case it's something beyond the browser limitations.

Thank you in advance!

Answer №1

Personally, I find that method to be quite cumbersome. It may be worth exploring Bootstrap CSS instead, as it is specifically designed to address this issue.

Alternatively, if you prefer the original method, you can simply enclose it within a <span> tag.

Example
<span style="color: red; background-color: blue;"><td>RandomData</td></span>

Keep in mind that these are just suggestions. Someone else may have a better approach when dealing with the first and second child elements.

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

What is the method for creating a button that has a gradient background and no border, but is still the same size as a button that has a border (

My code is based on Bootstrap v4 and I am facing an issue with creating gradient backgrounds for primary buttons that also use outline. The challenge is to maintain the same height and width for both buttons without the 2px border on the primary buttons. G ...

Error occurs when SRCSET loads the wrong size because "sizes" parameter is missing

According to the guidelines, when sizes is not specified in the image attribute, the browser should automatically calculate the required size based on CSS rendering. In this scenario, my image is 300px and the browser should select the 300px image. Howeve ...

Spinning with animation in jQuery

Greetings! I am in the process of creating a popup box that will appear upon clicking the Login button. My aim is to produce a popup box with a rotating effect, however, my attempts have not been successful so far. You can view the code snippet on JsFidd ...

Javascript-created HTML elements are failing to display on the webpage

As a newcomer to javascript, I am trying to dynamically create HTML elements using javascript for a class project. However, I am facing an issue where nothing is displaying on my page. Any help or guidance on what I might be missing would be greatly apprec ...

Generate a fresh standard table by extracting rows that are both visible and filtered from a DataTable

One of my challenges involves working with a DataTable that has paging, filtering, and the ColVis plugin for column visibility. My goal is to extract the visible and filtered data from all pages when a button is pressed, and then create a new regular table ...

Leveraging $implict for transferring several parameters

Need help with creating a recursive template that can accept multiple parameters: <ng-container *ngTemplateOutlet="testTemplate; context: {$implicit:jsonObj1}"> </ng-container> <ng-template #testTemplate let-Json1> </ng-template> ...

I recently encountered an issue where the Google Chrome Element Inspector (Developer Tools) unexpectedly removed an HTML element from

While using WordPress, I noticed a strange issue on the admin side when utilizing Google Chrome v.32 Element Inspector (Developer Tools) - some of the elements in my HTML seem to disappear. However, when I view the page without the Developer Tools, all the ...

Conceal the scrollbar track while displaying the scrollbar thumb

Hey there! I'm looking to customize my scroll bar to have a hidden track like this. Everyone's got their own style, right? ::-webkit-scrollbar{ width: 15px; height: 40px; } ::-webkit-scrollbar-thumb{ background-color: #DBDBDB; borde ...

vee-validate - Standalone form validation with distinct procedures

I currently have a situation where I am dealing with two forms, each in separate steps and having their own submit button. Using $validator.validateAll() validates all the inputs on the page, but I specifically need validation for each form individually. ...

unable to connect to the web service using webview

When attempting to call a web service or display an alert, I am encountering some issues: Here is the code from my activity: mWebView = (WebView)findViewById(R.id.webViewRootAciviy); mWebView.setWebViewClient(new WebViewClient()); mWebView.setWebChromeCl ...

Dynamic text formatting tool with mathematical equations support, media recording/uploading capabilities, and an innovative drawing feature

Seeking a robust text editor with the ability to handle math equations, record/upload media, and include a drawing tool for integration into my website. Are there any internet tools available (free or commercial) that offer these features? I have come ac ...

Calculate the total width of LI elements and apply it to the parent UL or DIV

Is there a way to calculate the Total LI width and then set the width for the parent div? Here is an example of my code: <ul> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds&l ...

`Mark a Wordpress post as read`

Is there a way to add a class to entries that have been read on the index page? Would it be best to use cookies or sessions for this purpose? I could use a little assistance with figuring out the most efficient way to do this. Thanks! ...

Having trouble finding a solution to prevent code from automatically adding a class in jQuery/JavaScript?

I am currently in the process of customizing the FlexNav Plugin. I have made a modification to allow sub-menus to open on click instead of hover. However, a new issue has arisen where it requires two clicks to open a submenu. Upon investigation, I have i ...

I am facing an issue where my Javascript hide and show function is not working properly when clicked. Despite not giving

I am currently working on a Javascript onClick function to toggle the visibility of content in a lengthy table. I initially set part of the table's class to display: "none" and added a button to show the hidden content when clicked. However, nothing i ...

The DOM assigned a new source to an image

Currently, I am working on a project that involves both jquery and PHP. In this project, users are able to upload images which are then displayed in blocks. The uploading functionality is already working, but I am facing an issue with setting the image sou ...

Tips for verifying several CSS attributes in a jQuery code

I wrote the script below: $('#copyright, #credit, #doom a').each(function () { if ($(this).css('font-size') != '15px') { document.location.href = "http://www.example.com"; } }); This script checks the CSS pro ...

How can I add a label to a button group created with Bootstrap?

The Nu HTML checker is throwing an error The value of the for attribute of the label element must be the ID of a non-hidden form control. <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> & ...

The paragraph fails to trigger the CSS :hover effect when I assign it an ID

Here is an example of a CSS3 transition with ease effect: HTML <div class="button"> <a href="#" onMouseOver="clicksound.playclip()"></a> <p id="myId" class="top"></p> </div> CSS * { pad ...

Numerous Selection Boxes

I came across this code snippet on the web. How can I insert the output into an email? Usually, I follow this format: $name = $_POST['name']; $email_body = "$name"; I want to incorporate the output of this code into my $email_body variable. Is ...