搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Delete an element on a webpage

more options

Okay so basically for example lets say i want to permanently just for my screen have this image deleted/or hidden whatever how can I do this without using an extension?

I believe someone brought up usercontent.css?

Okay so basically for example lets say i want to permanently just for my screen have this image deleted/or hidden whatever how can I do this without using an extension? I believe someone brought up usercontent.css?
附加的畫面擷圖

所有回覆 (1)

more options

In your other thread, you said you didn't want to use an add-on, you wanted to do it the hard way. ;-)

The userContent.css file holds style rules. For example:

selector { display: none !important; }

The trick is to figure out what CSS selector is associated with the element you want to hide, and it needs to be specific enough not to hide other things you don't want to hide. This is going to differ from one page to the next and typically takes some "hands on" work.

You already know how to use the Inspector, so you might find a unique selector based on an id, or one based on a class that you can make unique based on an ancestor element.

For a deeper dive: https://developer.mozilla.org/docs/Learn/CSS/Building_blocks/Selectors

To set up a userContent.css file, you use the same steps as a userChrome.css file but the file name is different. Also, you need to know about this feature if you want your rule only to apply to particular sites or pages:

https://developer.mozilla.org/docs/Web/CSS/@document

Note: Firefox requires it to be written with -moz- as @-moz-document.