كيفية تغيير لون أيقونة الرأس؟

هذا هو شكل منتدانا حاليًا…

سنقوم بإعادة هيكلة مخطط الألوان الخاص بنا. سيكون الرأس باللون الأخضر مع شعار أبيض في الرأس.

أواجه صعوبة في معرفة كيفية تغيير ألوان أيقونة العدسة المكبرة وأيقونة قائمة الهامبرغر في الرأس. هما رماديان حاليًا، وهو ما سيبدو سيئًا جدًا فوق رأس أخضر. كما أن الأيقونات البيضاء ستتناسب مع شعار الرأس الجديد.

لقد بحثت في قائمة المظهر ورأيت خيارًا يُسمى “الرئيسي للرأس”، والذي يذكر في وصفه أنه يغير النصوص والأيقونات في رأس الموقع. ومع ذلك، فقد قمت بالفعل بتعيينه على الأبيض ولم يتغير شيء. هل توجد طريقة أخرى لتغيير لون هاتين الأيقونتين؟

3 إعجابات

The icons are a bit transparent, which might be throwing you off (that’s why they look grey instead of white when the header_primary color is set to white).

You can add some custom CSS to change this

.d-header-icons .icon {
  color: red; // custom color, if needed
  &.btn-flat .d-icon {
    opacity: 1; // remove transparency 
   }
}
10 إعجابات

Hi,

I have this CSS:

header{
    
    height: auto !important;
    
    .wrap{
        padding:14px 0;
    }
    
    .btn-flat .d-icon{
        opacity: 1 !important;
    }
    
    .d-header-icons .icon{
        color: #ffffff;
        padding: 0.4em;
    }
    
    .d-header-icons .icon:hover{
        background-color: #ffffff;
        opacity: 1 !important;
        color: #001d4d;
    }

However, perhaps as we are now on one of the latest releases, now the home, search, and menu icons are greyed out. Can you explain how to make these icons white with opacity of 1? Did any of the selectors change?

Yes, these selectors are a little more specific now and we removed the opacity entirely in favor of using a solid color (there was a bug in Safari where SVG icons were clipped slightly because of the opacity).

You can remove anything you have related to opacity, and do this

.d-header-icons .d-icon {
   color: #fff; 
}

.d-header-icons .d-icon:hover {
   background-color: #fff; 
   color: #001d4d;
}
8 إعجابات

I have a similar problem as the OP, probably somewhat simpler: For some reason the colour of the header icons got darker for no apparent reason (I assume it was related to the tidy-up measures on your side). Since my header is a darkish, I want the icons brighter.

I tried this

and am happy with the result. But I can’t seem to figure out how the hover settings work. With only the above css, my hover looks like this:

image

So the icon turns grey again, which is okay, but I’d like to try some other tints on it. The background seems to turn white (or almost white), which I would like to change to make it coherent with other menus.

I tried

.d-header-icons .d-icon:hover {
   background-color: #b0cee8; 
   color: #fff;
}

but it gives me this:

image

How do I get the whole box to change color? And I don’t understand why the icon itself doesn’t stay white…

And while I’m at it: My new topic button also suffered. The colour of the + icon is no longer the same as the text:

image

My CSS for the button is (and has always been):

@import "common/foundation/variables";

#create-topic {
    background-color: $tertiary;
    color: $secondary;
}

#create-topic:hover {
    background-color: $tertiary-high;
    color: $secondary;
}
4 إعجابات

Hey, something has changed since your suggestion. I’m not sure why but this isn’t working for me either. CSS sheet looks like this:

    .custom-header-links a:hover {
    background-color:#346A77;
    }

    .d-header-icons .d-icon {
       color: black; 
    }

    .d-header-icons .d-icon:hover {
       background-color: #346A77; 
       color: red;
    }

The icons and the hover look like this–whatever color I make the icons or the hover it doesn’t “take”:

When I inspect the element it is showing that the style is there, but it’s not cascading for some reason. Any ideas?

image

I have installed custom headers but that wouldn’t be changing anything would it?

Many thanks

Update: the following code works and @tophee this should solve yours too:

.d-header-icons .d-icon {
   color: black !important;
}

.d-header-icons a:hover {
   background-color: #346A77 !important;
}
4 إعجابات

Thank you for the code.

I’m posting this in case someone runs into the same issue as me, but depending on the combination of colors you are using for your header and your icons (my header is a dark color), I was getting the right color combinations for my icons with the code you provided:

.d-header-icons .d-icon {
color: white !important;
}

.d-header-icons a:hover {
background-color: #789946 !important;
color: white !important;
} 

However, whenever I clicked on the header icons and hovered out of them, the background reverted to a solid white color, which did not work as my header is dark and my icons are set to white. So on hovering out of them (after a click), they would show as a solid white rectangle). To fix this, all I had to do was also set the state for “a”, not just “a:hover” as in the above posts (#93bb54 being the same color as my header):

.d-header-icons .d-icon {
color: white !important;
}

.d-header-icons a:hover {
background-color: #789946 !important;
color: white !important;
} 

.d-header-icons a {
background-color: #93bb54 !important;
color: white !important;
}

Voila!

Hey @awesomerobot, why doesn’t

.d-header-icons .d-icon {
color: white !important;
}

work on other icons like this envelope icon in a conversation, which is also d-icon if I inspect the element?

Screen Shot 2019-12-18 at 13.41.50

.d-header-icons specifically refers to the nav on the right.

For the PM title icon, you’ll need

.extra-info-wrapper .private-message-glyph { color: red }

For other topic statuses, like pins and locked topics you can use

.extra-info-wrapper .topic-statuses .d-icon { color: red; }

5 إعجابات

I added some custom icons in SVG, but I can’t change their color using CSS. They are always black. I can change the opacity, size … but never the color.

I tried using the above examples, but none returned the expected result.

.list-controls .btn .d-icon{
   color: #2CC3D5 !important;
   opacity: 0.5;
}

image

I tried for the header icons too.

What am i doing wrong?

Does the icon have a color defined inline in the SVG code? It would probably look something like this:

If so you can either remove it, or change the value to currentColor.

3 إعجابات

Hey guys,
I have a problem when:

  1. I click on the menu (looks great till here)
  2. When I move the mouse away, I need the icon to change color just as the background does because the icon gets hidden behind the white:

4-3-2020 9-59-08 AM

Try:

.drop-down-mode .d-header-icons .active .icon {
    background: black;
}
إعجابَين (2)

كيف يمكنني تغيير تنسيق CSS لأيقونة معينة؟

<svg class="fa d-icon d-icon-bolt svg-icon svg-node" aria-hidden="true"><use xlink:href="#bolt"></use></svg>

هذه هي الأيقونة التي أحاول تطبيق تنسيق CSS عليها

تفضل، @Juless

هذه الأنواع من محددات CSS المحددة جدًا يجب أن تعمل، لكنها نادرًا ما تُستخدم لأنها عادةً لا تكون هناك حاجة إلى هذا القدر من التحديد:

svg.fa.d-icon.d-icon-bolt.svg-icon.svg-node{
  /* CSS الخاص بك هنا */
}

ومع ذلك، في الممارسة العملية، يجب أن يعمل هذا المحدد البسيط بشكل جيد:

svg.d-icon-bolt{
   /* CSS الخاص بك هنا */
}

أتمنى أن يكون هذا مفيدًا.

ربما يمكنك حتى “الاستغناء عن” هذا:

.d-icon-bolt{
   /* CSS الخاص بك هنا */
}
إعجابَين (2)

استخدمت هذا المحدد وعمل بشكل ممتاز. شكرًا لك @neounix، كنت مفيدًا جدًا.

لدي نفس الموقف مثل Sentinelrv. قمت بتعديل header_primary إلى اللون الأبيض وطبقت أيضًا CSS المخصص الموصى به على كل من قوالباتي، لكن عدسة المكبرة وقائمة الهامبرغر لا تزال رمادية.

أنا أيضًا لا أستطيع تغيير ألوان قائمة الهامبرغر/الشريط، أيقونة البحث/العثور تغيرت - لقد جربت جميع النصائح المذكورة أعلاه وأكثر من خلال فحص الأشياء في متصفح الويب ولكن (لست مطور ويب) فشلت. هل توصل أحد إلى حل لهذه المشكلة؟

بالنسبة للأيقونات العلوية على الجانب الأيمن، في common-css الخاص بموضوع أو مكون سمة:

.d-header .d-header-icons .d-icon  {
    color: <header icons color> !important;
    &:hover {
        color: <header icons hover color> !important;
    }
 }

بالنسبة للأيقونة الهامبرغر في وضع قائمة الشريط الجانبي:

.d-header .header-sidebar-toggle button .d-icon {
    color: <hamburger icon color> !important;
    &:hover {
        color: <hamburger icon hover color> !important;
    }
}

<header icons color>, <hamburger icons color>, <header icon hover color>, <hamburger icon hover color> = قيم سداسية عشرية، أسماء ألوان، أو متغيرات ألوان السمة. يمكنك أيضًا تحديد background-color إذا كنت ترغب في تغيير لون خلفية الأيقونة.

ملاحظة: إذا كنت تستخدم وضع القائمة المنسدلة للهامبرغر بدلاً من الشريط الجانبي، فإن المقتطف الأول لأيقونات الرأس على الجانب الأيمن سيشمل أيضًا أيقونة الهامبرغر.

4 إعجابات