Striped Table With Period

Striped Table With Period

gultekinbgultekinb Posts: 1Questions: 1Answers: 0

I use "table-striped" class to add striped rows to my table. But I want to stripe my table 4 by 4. I mean first 4 row is gray, next 4 row is white then the next 4 row is gray again. Is there any way to choose the period of stripe?

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited April 2023

    There isn't anything built into Datatables for this. You might be able to use . Maybe this SO thread will have something that will work for you.

    Right click on one of the rows and use the browser's inspect tool to see what selector Datatables is using for your rows, for example table.dataTable tbody tr. Also you might need to remove display or stripe classes from the -table tag. See the table classes docs for details. You might have additional steps if you are using a styling framework.

    See this example using an adjusted selector from the first response in the SO thread.
    https://live.datatables.net/bopomepi/1/edit

    Kevin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Just a little addition here, use the nth-child() selector which can be setup to do what you want.

    Allan

Sign In or Register to comment.