Implementing alternating row shades using Bootstrap

I am attempting to apply shading to every other row in a table.

Here is the code snippet:

dt:nth-child(4n+1) ,dt:nth-child(4n+1) +dd{
  background-color:silver;
}
<div class="col-sm-2 tabularData">
  <dl class="dl-horizontal">
   <dt>Booking</dt>
   <dd class="ng-binding"></dd> 
   <dt>Shipper</dt>
   <dd class="ng-binding"></dd>
   <dt>Consignee</dt>
   <dd class="ng-binding"></dd>
   <dt>VVD</dt>
   <dd class="ng-binding"></dd>
  </dl>
</div>

However, the current output appears as follows:

https://i.sstatic.net/ZwObh.png

Answer №1

To add some flair to your tables, try using the odd-even styling technique like this:

table tr:nth-child(odd) {
background-color:silver;
}
table tr:nth-child(even) {
background-color:gold;
}

Answer №2

After some investigation, it was discovered that the issue stemmed from the spacing between the columns. The fix for this problem is to adjust the margins on the dd element to be zero.

.col-sm-2.tabularData dd {
  margin:0;
}

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

Steps for revealing all the information from a database when clicking on the 'Read More' button

I recently set up a database called Magazine, featuring a table named social_media. This table consists of 5 columns: ID, Headline, Author, Content Short, Content. The Content Short column contains condensed versions of the articles which are displayed on ...

Is it possible to apply a PNG icon collection using CSS?

Throughout various examples, jQuery plugins, and CSS-styled HTMLElements, I have observed the setting of icons on an image with multiple options. I am eager to implement this practice in my own apps. https://i.sstatic.net/WDCH3.png For instance, in the ...

Is it necessary to have uniform spacing between links in a responsive navigation menu?

I am attempting to create a horizontal menu navigation system. I have multiple links in the navigation, and my goal is to evenly space them horizontally. Is there a way to achieve uniform spacing between links in a horizontal menu? HTML: <div id= ...

Display a close button for every individual item and use JavaScript to conceal the current item

I have a list that contains input fields along with delete link elements. I want to display the delete link element when the user hovers over the respective input field. Additionally, clicking on the close button (X) should hide the entire list item (li) f ...

Utilizing jQuery for Summation Calculation

How can I use jQuery to calculate the total sum of prices for all products in a table with the column name "price"? Once calculated, how do I store this sum in a variable? <table id ="tab"> <th>Product</th><th>Price</th> ...

How to Align position:relative Divs Horizontally Using CSS

My goal is to showcase content from my website located at . I want to have the ability to place this content into a designated div where I can easily center or style it as needed. The issue arises when attempting to float the content, as it doesn't fu ...

Executing animation after the completion of a transition

Is there a way to synchronize the bounce animation with the scaling of an object, so that it appears smooth and fluid? I've tried using the animation delay property along with the transition delay property, but they don't seem to align correctly. ...

Updating the Hero Image

Scenario: In my project directory, under Product -> src -> static -> ostatic [ there are two folders named css and images ] -> images -> where all the images can be found. I am using bootstrap and attempting to set a background-image for j ...

Struggling to make the height attribute work in Bootstrap 4 alpha

I'm currently in the process of learning Bootstrap, and I've encountered an issue with the height attribute in version 4 (for example: "row h-25") not functioning properly. I attempted to add another CSS rule that sets the height of "container-f ...

Wrapping HTML input elements in a div for alignment

I need help aligning the inputs in my form to match the image provided https://i.sstatic.net/AXhlp.png. I attempted to center the div using <center>, but I am unsure how to properly align the elements based on the image reference. <center> ...

What are the steps to view my HTML webpage on a smartphone?

Recently, I successfully created an HTML webpage with CSS and JS that looks and functions perfectly on my PC. However, when attempting to access it on my phone, I encountered some issues. Despite transferring all the necessary files to my phone, only the ...

What is the best method for creating table column text within a Bootstrap Modal through JSON data?

I am currently working on creating a table by using key value pairs from a JSON object. The keys will represent column-1 and the values will correspond to column-2. The desired output can be viewed at this link. I am wondering if there is a standard method ...

Creating a CSS grid layout with dual columns to dynamically adjust and accommodate two items in each row

I am attempting to create this layout using CSS grid: https://i.sstatic.net/Ktbnm.png The goal is to have an input and a textarea. The textarea should be of the size of 2 inputs. If there is already a textarea in the previous column, the next column shou ...

Having trouble extracting data from Moz Bar through selenium using Python?

Having trouble retrieving the spam score from Moz bar using Selenium WebDriver? I've attempted various methods such as XPath, class, and tag name without success. Any assistance would be greatly appreciated: from selenium.webdriver.common.by import By ...

Preserving form input after an unsuccessful submission: A simple guide

As a beginner in the coding world, I am currently working on creating a contact form using PHP. One of the features I've included is a reCaptcha that must be checked before submitting the form. However, if the user forgets to check the reCaptcha and h ...

What is the best way to center align an element while having another element situated directly below it?

I want to create a grid of "clock" elements, with five clocks in each row. Below each clock, I'd like to display the DAY and DATE centered with the clock (day on top line, date below). Since I'm new to html/css, I appreciate your patience. Here&a ...

Using the Croppie plugin to crop an image before uploading via jQuery Ajax in PHP

I've successfully implemented a code snippet that allows image cropping using PHP, jQuery, and Ajax with the Croppie plugin. Currently, I'm facing an issue while trying to include additional input values along with the image upload process. I ...

Using Angular's [ngIf], [ngIfElse], and [ngIfElseIf] functionalities enables dynamic content rendering

Currently, I have the following code snippet: <ng-container *ngIf="someCondition"> <ng-template [ngIf]="cd.typedType === 'first'" [ngIfElse]="Second"> <div class="row"> fir ...

Creating a sticky menu in a column using affix with a CSS bootstrap list-group

My goal is to develop a sticky menu utilizing CSS Bootstrap affix and the list-group menu. I have successfully implemented most of it, except for one issue when the user scrolls down. Upon scrolling down, the menu expands to fill the entire width of the ...

Can you identify the syntax of this LESS variable called @grid-breakpoints with breakpoints for xs at 0, sm at 576px, md at 768px, lg at 992px, and xl at

While exploring the bootstrap less port, I came across this interesting syntax: @grid-breakpoints: xs 0, sm 576px, md 768px, lg 992px, xl 1200px; What exactly is this? It doesn't seem to be a map or an array... How can I retriev ...