我有一个跟踪像素,不幸的是在我的页脚底部造成了一个小白条。隐藏像素的最佳方法是什么?
我正在考虑将它(和我的其他像素)放在一个position: absolute
div 中,它可以正确隐藏栏,但我不确定这是否会阻止像素在某些浏览器上工作。
来自谷歌支持:
<img src="TRACKING-PIXEL-URL-GOES-HERE" style="position:absolute; visibility:hidden">
<img src="TRACKING-PIXEL-URL-GOES-HERE" style="display:none">
<img src="TRACKING-PIXEL-URL-GOES-HERE" width="0" height="0">
你可以给它一个display: none
CSS 声明,或者你可以给页脚一个负的底部边距值margin-bottom: -1px
My tracking pixels were getting added automatically via javascript but all of them had a width and height of 1 defined <img src="http://tracking.com/bla" width="1" height="1" />
so I hid them by targeting those attributes:
img[width="1"][height="1"] {
display: none;
}
You could alternatively target the src:
img[src="http://tracking.com/bla"] {
display: none;
}
您还可以在 CSS 中屏蔽更大范围的 1 像素链接,包括基于数据块的图像,如下所示:
*[src*='FIRST-PART-OF-TRACKING-PIXEL-URL-GOES-HERE'],
*[src*='data:image'] {
display: none;
}