The magic of CSS table manipulation

I'm having trouble with the nth-child selector to control the display of table 2. Specifically, I want to show only rows 11-20 in table 2 but I can't seem to get it right. Any suggestions?

Currently, Table 1 is displaying rows 1-10 correctly. Table 2 is showing rows 11-end instead of stopping at 20 like I intended. Table 3 is displaying rows 21-30 as expected.

table.style1 {
    border-collapse: collapse;
}

table.style1 > tbody > tr:nth-child(n + 11) {
    display: none;
}

table.style2 {
    border-collapse: collapse;
}

table.style2 > tbody > tr:nth-child(-n + 10):nth-child(-n + 19) {
    display: none;
}

table.style3 {
    border-collapse: collapse;
}

table.style3 > tbody > tr:nth-child(-n + 20) {
    display: none;
}

Answer №1

Instead of:

table.category3 > tbody > tr:nth-child(-n + 10):nth-child(-n + 19) {
  visibility: hidden;
}

try:

table.category3 > tbody > tr:nth-child(-n + 10),
table.category3 > tbody > tr:nth-child(n + 21) {
  display: none;
}

Answer №2

Here is a suggestion for you to try out.
Check out this example

table.style1 {
border-collapse: collapse;
}

table.style1 > tbody > tr:nth-child(n + 11) {
display: none;
}

table.style2 {
border-collapse: collapse;
}

In the next section, we have some more CSS rules for table style 2:
table.style2 > tbody > tr:nth-child(-n + 10), table.style2 > tobdy > tr:nth-child(n+21){
display: none;
}

table.style3 {
border-collapse: collapse;
}

table.style3 > tbody > tr:nth-child(-n + 20) {
display: none;
}

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

Displaying elements above my React sidebar

I am working on developing a Login application with a landing page using React Router and Redux. In order to have a Sidebar that is always present in all the components within the application, I have setup the Sidebar component as a route that is constantl ...

Exploring ways to traverse through Map values

My app initially displays a grid of cells that I would like to fill in with data. Here is the initial view: https://i.sstatic.net/AgI16.png -> As the app runs, each rider's score will be updated dynamically like this: https://i.sstatic.net/HOPoN ...

Retrieve the row from the table using the "let" keyword

I'm attempting to retrieve the row of a table by selecting a radio button. My goal is to identify the selected row in order to access the experiment ID, but when I try this, the alert shows "Row index is: undefined." I found the code at: https://www. ...

Organizing files on a website for collaborative projects involving multiple team members

I am currently constructing a website with the following specifications: Pages are being loaded inline via AJAX. CSS, HTML, JavaScript, and PHP are all separated to facilitate collaboration on projects. While working on creating a dynamic <select> ...

What is the proper way to incorporate superscript into an HTML document?

<td>20<sup>o</sup>C</td> I am having trouble getting the 'o' to display as a superscript in my HTML output. Can someone please advise on how to properly add superscripts in an HTML page? Currently, I am only seeing 20oC ...

Utilizing the content of an HTML element within Ruby embedded code - a comprehensive guide

Below is the code snippet in question: <% @groups.each do |group| %> <tr> <td id="groupid"><%= group.id %></td> <td><a href="#dialog" name="modal"><%= group.title %></a></td> </tr> &l ...

Challenges with implementing ng2-auto-complete in Angular2

I successfully integrated the Angular 2 ng2-auto-complete component into my project by following this helpful tutorial. The code is also available on GitHub. The current challenge I am encountering involves the formatting of my data source. It is structur ...

CSS mysteriously malfunctions on certain iPhones

Key Concept Despite testing with responsive simulators and ensuring there were no issues, some iPhone users have reported problems with the style of my web page. Coding Essentials The page is designed to use 2 custom CSS files - one for screens larger t ...

The parent's height remains unaffected by the margins of its child element

My code snippet is concise: .parent{ box-sizing: border-box; } .child{ height: 100px; margin: 20px; background: red; } .a1{ background: green; } <!DOCTYPE html> <html> <head> </head> <body> ...

To enhance user experience, consider incorporating a 'Next Page' feature after the completion of every four paragraphs,

Here is a code snippet that can be used to print 'n' number of paragraphs: <% while(rs.next()){ String para=rs.getString("poems"); %> <p> <%=para%> </p> <!-- n number of p tags are printe ...

Place the icon directly below the text

Can anyone please advise on the necessary input to position the icon BELOW/UNDER the text? <a href="#"><div class="resume"> <h4><i class="fa fa-address-card" style='display: block' ></i> Resume</h4> </ ...

Tips on activating the overlay solely on the image without affecting the entire column

Currently, I am working on a project locally and do not plan to release it. However, I am facing an issue with making the overlay only appear on the image rather than covering the entire column. I came across some pre-built code on the w3 schools website ...

How can I embed input tag with the data-plugin attribute into a DOM element?

Can anyone help me with adding a data-plugin attribute to the "el" element using JavaScript? HTML <input type="text" data-plugin="datepicker" class="form-control" > JavaScript // Creating an input element var cellRight = row.insertCell(1); var ...

Creating a responsive image within a panel using Bootstrap

I've been struggling to make a responsive image fit inside a panel while maintaining its aspect ratio and ensuring none of it gets cut off. I've attempted various CSS tweaks with no success. My setup involves Bootstrap along with React.js using r ...

Utilize animation effects in jQuery to make text slide upwards and smoothly transition to a new text

I am currently working on developing a website that requires dynamic data changes. To enhance user experience, I aim to display the information in an animated format where text gracefully transitions by moving up and being replaced by new content emerging ...

BS4 Dynamic Countdown Clock

I have successfully integrated a countdown timer into my website, utilizing the following HTML code: <div id="clockdiv"> <div> <span class="days"></span> <div class="smalltext">Days</ ...

Encountering difficulties in running bootstrap on nodejs

As a beginner in node.js and bootstrap, I am eager to create my own personal website, so I found some tutorials to help me get started. After downloading bootstrap 2.0.2 and unzipping it, I organized the files by placing bootstrap and bootstrap-responsive ...

Tips on positioning a secondary navbar below a sticky navbar in Bootstrap 4

Currently, I am utilizing bootstrap 4 to create an application that features two navbars. Both of these navbars are intended to be fixed at the top, with the second navbar hiding as the user scrolls down. Here is the HTML code for the navbars: Navbar 1: ...

Tips for efficiently obtaining JSON Ajax data, saving it to local storage, and presenting it in a jQuery Mobile list view

Upon calling ajax to my server, I receive 1000 units of data which I then store in my local storage before displaying it on a jQuery mobile list-view. However, this process takes around 50-60 seconds to complete. Is there a way to optimize this and make it ...

Convert a String to JSON using either JavaScript or jQuery

Currently, I am developing a JavaScript animation script and I am aiming to allow individuals to define behavior declaratively within the HTML. This is the format I envision for my HTML: <div data-animation="top: 600, left: 600, opacity: 1, start: 0.2 ...