更改特定行的背景

发布于 2025-02-13 05:40:57 字数 340 浏览 0 评论 0原文

目前,我正在从事一个Book Store Web应用程序的项目。我想像一行一样更改行的背景,下一行是白色的,然后继续进行。我的任务是使用CSS执行此操作。

您可以在图片中看到。我想更改“小说”行灰色,我想要下一行“恐怖”保持白色并改变“冒险”行,然后这样。数据来自数据库一个,我无法一个一个接触它们。

Currently, I am working on a project which is Book Store Web Application. I want to change the background of the rows like one row is grey, the next row is white and goes on like this.Also my task is doing this using CSS.

enter image description here

You can see in picture. I want to change the "Novel" row grey, I want the next row which is "Horror" stay white and change "Adventure" row to grey and it goes on like this. The datas come from the database one by one and I cannot reach them one by one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

决绝 2025-02-20 05:40:58

由于您使用的是ASP.NET MVC,因此我会假设您正在使用Bootstrap。

您需要做的就是在< tbody></tbody>上添加.table striped

或遵循此示例:

<table class="table table-striped">
  ...
</table>

对于普通的CSS解决方案,请尝试此尝试。 :

tr:nth-child(even) {
  background-color: #f2f2f2;
}

bootstrap 5条纹桌文档:

Since you are using asp.net MVC I will assume you are using bootstrap.

All you need to do is add .table-striped on <tbody></tbody>

or follow this example:

<table class="table table-striped">
  ...
</table>

For a plain CSS solution try this:

tr:nth-child(even) {
  background-color: #f2f2f2;
}

Bootstrap 5 striped table docs: Striped table

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文