且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不同的页面中添加类

更新时间:2023-10-13 08:40:28

最简单的选择可能是使用 :target CSS选择器 [ ^ ]。



当你链接到第二页,在URL中指定目标块:

The easiest option would probably be to use the :target CSS selector[^].

When you link to the second page, specify the target block in the URL:
secondpage.html#block-1



然后使用:target 选择器应用样式:


Then apply the styles using the :target selector:

.block:target
{
    /* Styles for the active block here... */
}