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

Change the position of a div by clicking on different content menu buttons to make it go up

I have implemented move up and move down buttons in my context menu for multiple div drops. However, I am facing an issue with moving the div down after clicking the move down button. Here is the code snippet that I am currently using: $(".propertyClass" ...

Bootstrap allows for multiple items to be displayed on the same line, creating

I am currently utilizing Bootstrap framework and have a total of four items. However, the last item is displaying beneath the other three items instead of being on the same line. The current code snippet is as follows: <div class="text-center linksblok ...

Combining classes in SCSS to create more versatile styles

Here is some code snippet: input { border:1px solid black; color:#FFF; } Another snippet: .input { padding:0px 5px 0px 3px; } How can we use SASS/SCSS to achieve the following: input.input This will apply the .input class directly to ...

Combining two Angular expressions

I have two values to work with: {{columns.field}} and {{resultado.!!!}}. The challenge is that I need to include the value of {{columns.field}} inside the !!!, but I'm struggling to figure out how. I have to structure it this way because I am unsure o ...

Creating a SVG polygon using an array of points in JavaScript

Consider the following array containing points: arr = [ [ 0,0 ], [ 50,50 ], [ 25,25 ], ]; I would like to create an SVG polygon using this array. Initially, I thought the code below would work, but it doesn't: <polygo ...

Tips for transforming numerical date data into a string format

Is there a method to convert the numeric month in a table into a string format? <table style="width: 100%;"> <tr> <th>Date</th> <th>Total</th> </tr> <tr> <td id="date ...

Ways to align a nested list vertically

There are two nested lists: <ul> <li>First item <ul> <li> <a href="#">some item</a> </li> <li> <a href="#">some item</a> <</li& ...

Display iframe as the initial content upon loading

Seeking solutions for loading an iframe using jQuery or Ajax and outputting the content to the page once it has been loaded. The challenge lies in loading an external page that may be slow or fail to load altogether, leading to undesired blank spaces on th ...

In both Chrome and Edge, the default value for the <select> tag is successfully set, however, this functionality is not working in

I have defined two values in the created method, 2018 and My Name, and assigned them to separate data properties. These data properties are then passed as v-bind to a component. The issue I am facing is that in Chrome and Edge, both values are set as defa ...

What specific CSS selector should be targeted in order to modify the appearance of this button?

I'm attempting to alter the appearance of a button within my Wordpress site, but I've hit a roadblock in identifying the correct element to modify. So far, I've tried targeting: .input#chained-quiz-action-1, however, the button stubbornly re ...

Using HTML: The trick to obtaining selection offsets in relation to HTML tags

Let's say I have HTML code like this: <div> <p> start<span>span</span>end </p> </div> I am looking for a way to retrieve the offsets when text is selected, while still taking into account the presence of span ...

How can I perform a MySQL UPDATE using 2 parameters received from an AJAX request ($_POST)?

I am currently working on an AJAX call that updates a row in the database based on the ID (pid=38) and changes the value of a column to NULL depending on the button clicked (taskimg0). I have managed to make it work by hardcoding the value $_POST['dtf ...

Trouble with image rotation in jQuery/JavaScript slideshow

For more information, you can visit and click on the Canucks icon, which is located as the third icon below "information architecture and usability." I am attempting to set up a jQuery slideshow by utilizing a template I found online. However, I am encou ...

Display loader while waiting for file to be loaded

I am utilizing ajax to retrieve a file. The loading animation is functioning properly with the ajax request, however, the file size is notably large. I am interested in implementing a preloader that will display until the file has finished loading. ...

Updating backgroundPosition for dual background images within an HTML element using Javascript

Issue at Hand: I am currently facing a challenge with two background images positioned on the body tag; one floating left and the other right. The image on the left has a padding of 50px on the left side, while the image on the right has a padding of 50px ...

CSS in flexbox nested with no overflow utilized

I have created a basic "table" layout using flexbox. I want to implement horizontal scrolling for a specific part of the table by using overflow-x property. When you look at the provided code snippet, you'll notice that the CSS styles are only visib ...

The stick division shows some bouncy behavior when seen on a mobile device

When viewing on mobile, the #main-categories div seems to be jumping instead of smoothly sticking to the top. What could be causing this behavior? Here is the code snippet I have: var s = $("#main-categories"); var pos = s.position(); $(window).scroll(f ...

How to adjust the banner image placement in Squarespace

I need the banner image to shift position on smaller screens, specifically those with a max-width of 414px. I want the focus to be on showcasing a specific product (a building) located on the right side of the image. This building should only appear on wid ...

Tips for positioning a div between two vertically aligned input elements

I'm trying to figure out how to place a div between two inputs with the same height and vertically aligned. It seems like a simple task, but for some reason, the code below isn't working: input{ width: 35%; border: 1px solid #A7A7A7; ...

What is the best way to navigate through a webpage to find a specific folder and show its contents on the page?

My goal is to design a webpage where users can browse their computer for a specific folder, select it, and have its content displayed on the webpage. I am fairly new to creating pages, but I want to develop a platform where you can easily find and view f ...