纯CSS跟踪统计上报点击行为实例页面

回到相关文章 »

效果:

先打开控制台,切换到network选项卡,查看IMG请求,然后点击下面2个按钮:

代码:

CSS代码:
.button-1:active::after {
    content: url(./pixel.gif?action=click&id=button1);
    display: none;
}
.button-2:active::after {
    content: url(./pixel.gif?action=click&id=button2);
    display: none;
}
HTML代码:
<button class="button-1">按钮1</button>
<button class="button-2">按钮2</button>