# 有没有办法用CSS更换图片/图标？

**URL:** <https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692>\
**Category:** Development\
**Created:** [2024年八月28日 00:13 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692 "2024-08-28T00:13:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptainJ](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CaptainJ](https://meta.discourse.org/u/CaptainJ)\
**Post date:** [2024年八月28日 00:13 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/1 "2024-08-28T00:13:46Z")

</div>

我正在尝试大幅简化页眉菜单。我还没有找到其他人的解决方案，所以我的计划是将我们实际需要保留的几个链接添加到侧边栏，然后让页眉菜单只显示主要的通知选项卡。我差不多完成了，但是点击个人资料照片才能看到通知有点令人困惑，所以我想把个人资料照片改成铃铛图标。这可以做到吗？

这是我想要的效果，但希望在顶部空白框的位置显示一个铃铛图标：

 ![Screenshot 2024-08-28 at 01.11.36](https://global.discourse-cdn.com/meta/original/4X/8/1/6/816e70f392a3e2b9366813982f5accc4c23b1ee8.png)

抱歉，这似乎应该很简单，但我自己尝试了好几个小时都没有任何进展！

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2024年八月28日 03:41 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/2 "2024-08-28T03:41:41Z")

</div>

我认为[这个主题](https://meta.discourse.org/t/central-theme-header-user-icons/291526/4#step-3-add-the-widget-onto-the-header-replace-existing-user-icon-with-notification-bell-icon-3)解释了如何做到这一点。但我不知道它是否仍然是这样工作的。

---

<div class="post-metadata">

**Author:** ![CaptainJ](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CaptainJ](https://meta.discourse.org/u/CaptainJ)\
**Post date:** [2024年八月28日 12:54 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/3 "2024-08-28T12:54:47Z")

</div>

嗯，那可能不行。我还没有弄清楚如何使用 JavaScript，所以我想知道是否有一种方法只能使用 CSS 来交换图像/图标。不管怎样，谢谢！

---

<div class="post-metadata">

**Author:** ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)\
**Post date:** [2024年八月29日 08:08 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/4 "2024-08-29T08:08:31Z")

</div>

> [@CaptainJ](#):
>
> 我想知道是否有一种方法可以仅使用 CSS 来交换图像/图标

你好 👋

我制作了一个简单的主题组件来实现这一点。仅使用 CSS。

一些截图  
 ![Screenshot 2024-08-29 at 10.04.52](https://global.discourse-cdn.com/meta/original/4X/c/e/4/ce4d50779cad7c4d43591d5c84be1aea1cab0bfb.png)

您可以在此处观看实时演示。

> **['Header Avatar to Bell Icon' by @Don](https://discourse.theme-creator.io/theme/Don/header-avatar-bell-icon)**
>
> A customization for Discourse shared on Discourse Theme Creator

您可以在此处找到该主题组件。

> **[GitHub - VaperinaDEV/header-avatar-to-bell-icon: This theme component will change the header avatar...](https://github.com/VaperinaDEV/header-avatar-to-bell-icon)**
>
> This theme component will change the header avatar to bell icon

---

<div class="post-metadata">

**Author:** ![CaptainJ](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CaptainJ](https://meta.discourse.org/u/CaptainJ)\
**Post date:** [2024年八月29日 11:54 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/5 "2024-08-29T11:54:26Z")

</div>

太棒了，谢谢！

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2024年九月28日 11:54 UTC](https://meta.discourse.org/t/is-there-a-way-to-change-images-icons-with-css/323692/6 "2024-09-28T11:54:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
