Modifying the color scheme of the table background and text

After finding a code example online to assist with creating a table in my project, I am faced with the challenge of changing the background color of the white rows to match the dark blue used for others. Additionally, I cannot figure out how to change the text color to white so it is visible against the dark blue background. Any insights on what I may be missing?

.styled-tableBlue {
  border-collapse: collapse;
  margin: 25px 0;
  font-size: 0.9em;
  font-family: sans-serif;
  min-width: 400px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}

.styled-tableBlue thead tr {
  background-color: #324655;
  color: #ffffff;
  text-align: left;
}

.styled-tableBlue th,
.styled-tableBlue td {
  padding: 12px 15px;
}

.styled-tableBlue tbody tr {
  border-bottom: 1px solid #152027;
}

.styled-tableBlue tbody tr:nth-of-type(even) {
  background-color: #152027;
}

.styled-tableBlue tbody tr:last-of-type {
  border-bottom: 2px solid #152027;
}

.styled-tableBlue tbody tr.active-row {
  font-weight: bold;
  color: #ff6600;
}
<table class="styled-tableBlue">
  <thead>
    <tr>
      <th>Installers</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><b>&nbsp;Download</b></td>
      <td><b>&nbsp;Installer Name</b></td>
    </tr>
    <tr>
      <td><img src="images/downloadArrow.png" width="20" height="20" alt="Download" />&nbsp;</td>
      <td>6000</td>
    </tr>
    <tr class="active-row">
      <td>Download Btn Here</td>
      <td>5150</td>
    </tr>
    <tr>
      <td>Download Btn Here</td>
      <td>7000</td>
    </tr>
    <tr>
      <td>Download Btn Here</td>
      <td>7000</td>
    </tr>
    <tr>
      <td>Download Btn Here</td>
      <td>7000</td>
    </tr>
    <tr>
      <td>Download Btn Here</td>
      <td>7000</td>
    </tr>
    <!-- and so on... -->
  </tbody>
</table>

Answer №1

The reason why the white rows do not have a blue background color is because of this particular rule:

.styled-tableBlue tbody tr:nth-of-type(even) {
    background-color: #152027;
}

When using :nth-of-type(even), it applies the color to every even row. If this part is removed, all rows would be blue instead. By changing the color property to white, the text on those rows would also become white.

An alternative solution is to replace it with:

.styled-tableBlue tbody tr {
    background-color: #152027;
    color: white;
}

To maintain consistency, you can use "#ffffff" in place of "white", or opt for the shorter version "#fff".

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

Set the style to be displayed as a block element

I am working on a Rails application that contains some <li> elements with the CSS property display: none;. I want these elements to only appear on the page when they are being dragged. However, there are some elements that do not have the display: no ...

Password Reset Function Malfunctioning

Could somebody please assist me in resolving the issue with the reset email? When attempting to reset it, I received the following message: An email with further instructions has been sent. However, I did not receive a reset link. Here is the reset file. ...

Content and visual side by side

My logo and header image are giving me trouble. Whenever I attempt to center the header image, it keeps moving to the next row. How can I make sure it stays on the same row? Check out our website Thank you ...

Removing a function when changing screen size, specifically for responsive menus

$(document).ready(function () { // retrieve the width of the screen var screenWidth = 0; $(window).resize(function () { screenWidth = $(document).width(); // if the document's width is less than 768 pixels ...

Limit access to a specific route within the URL

Is there a way to ensure that users can access and download myfile.pdf without being able to see or access /root, /folder, or /subdirectory in the URL? This functionality can be implemented using HTML, Angular 6, ReactJS, or similar frameworks. ...

Margin challenge in CSS

Just starting out with CSS, so please be patient with me. I'm currently working on customizing a form and everything is looking good, except for the confirmation label which is located in a div. I've managed to create space between other elements ...

Using TypeScript with Angular, you can easily include parameters to HTML tags

I have an HTML element that looks like this: eventRender(info){ console.log(info.el); } This is the output I'm seeing: https://i.stack.imgur.com/G0hmw.png Now, I want to include these attributes: tooltip="Vivamus sagittis lacus vel augue ...

Leverage nearby data using MediaSource

I am currently working on creating a local video player using nwjs (node-webkit). I have successfully played local files by setting their path as the src attribute of the video element. Now, I want to explore using MediaSource and potentially URL.createObj ...

Is there a way to obtain a comprehensive list of zip codes that are traversed by your route directions?

I have been searching through the Google Maps API (both Android and Web) but have not come across any references on how to retrieve a list of all the zip codes that are traversed by a given driving route. Could it be possible that I am missing something, ...

Clear out any unnecessary white space beneath the content on your webpage

I am relatively new to Web Development and currently following Colt Steele's udemy course. I have been working on a landing page, but as I try to set the height of HTML to 100%, it leaves whitespace at the bottom. After some research, I suspect that t ...

Utilizing itemprop tag independent of itemtype declaration

My question is whether it's possible to use the itemprop attribute without using the itemtype. Can this be done? If so, how does using these attributes impact SEO? Is it recommended to always use itemtype? I assume it would be beneficial, but what if ...

Using jQuery to encode an ampersand in a URL

I am facing an issue where some URLs with & in them need to be converted to HTML entities using jQuery. The original code looks like this: <div id="box"> <a href="http://domain.com/index.html&location=1">First URL</a> &l ...

The content inside the inner div does not stretch to match the height of its parent element

I want to address a specific issue I am facing with my div structure. Although it may seem similar to other questions on StackOverflow, none of the existing solutions have worked for me. The problem is that I have two child divs inside a parent div. The h ...

What is the process for generating a GET request for selected checkboxes and subsequently showcasing the data on an HTML webpage?

Currently working on an app project and need assistance with implementing a feature. I have successfully set up a POST method for the checkboxes that are checked, but I am unsure how to retrieve this data and display it on my HTML page using a GET method ...

What is the best way to ensure the logo is centered when the screen size reaches 750?

Looking to center the logo on a media screen size breakpoint? View the photo (Here): https://i.stack.imgur.com/UnB2F.png Check out my code below: .logo img { padding: 15px; width: 125px; } <nav> <ul class='nav-bar'> < ...

Creating a Dojo HTML template involves incorporating repetitive sections of HTML code within the template structure

I am working with a custom Dojo widget that is based on a template and has an HTML template stored in a separate .html file. Here is the Dojo Widget code snippet: define("dojow/SomeWidgetName",[ "dojo/_base/declare", "dijit/_WidgetBase", "dijit/_Templat ...

The parser for PHP CSS struggles with interpreting semicolons within property values

I encountered an issue while using a function to parse CSS files. The problem arises when the property values contain semicolons, causing it to break. Here's an example snippet from the CSS file: #logo { background-image: url("data:image/png;base ...

Guide to activating form elements using a JQuery function

I need help setting up a form with 11 rows and 11 columns. By default, the form fields should be disabled, but when I click on an "EDIT" button, they should become enabled. Any assistance would be greatly appreciated. Thank you in advance. Here is my edit ...

The inline-block property can become unstable when dealing with a large number

When I create a parent container div with three child divs and set the display property to inline-block, everything looks great on jsfiddle CSS #container { border: 1px solid blue; padding: 2px; display: inline-block; } .child { width: ...

Guide to horizontally aligning a div with a dynamic width in the center

After extensive research, I discovered that setting a width allows you to center a div using margin: 0 auto along with left: 0;, right: 0, and position: absolute. However, all the examples I found had a specified width. In my specific case, I need to cent ...