How to Change Header Icon Color?

This is currently what our forum looks like…

We are going to rebrand our color scheme. The header will be green with a white header logo.

I am having trouble figuring out how to change the colors of the magnifying glass and the hamburger menu icon in the header. They are currently gray, which will look awful on top of a green header. The white icons will also match the new header logo.

I’ve looked in the theme menu and I see an option called header primary, which says in the description that it changes text and icons in the site’s header. However I’ve already set it to white and nothing has changed. Is there another way to change the color of these two icons?

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 
   }
}

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;
}

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:

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:

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;
}

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?

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;
}

코드를 공유해 주셔서 감사합니다.

제가 겪은 동일한 문제를 다른 분들도 마주할 수 있을까 해서 이렇게 글을 올립니다. 헤더와 아이콘에 사용하는 색상의 조합에 따라(제 헤더는 어두운 색입니다), 제공해 주신 코드로 아이콘에 적합한 색상 조합을 얻을 수 있었습니다:

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

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

하지만 헤더 아이콘을 클릭한 뒤 마우스를 아이콘에서 떼어 내면 배경색이 다시 단색 흰색으로 돌아갔습니다. 제 헤더는 어두운 색이고 아이콘은 흰색으로 설정되어 있어 이 상태에서는 제대로 표시되지 않았습니다. 즉, 클릭 후 마우스를 떼어 내면 아이콘이 단색 흰색 사각형으로 보였죠. 이 문제를 해결하기 위해 위에서 언급된 "a:hover"뿐 아니라 “a” 상태에도 스타일을 적용해 주면 되었습니다(여기서 #93bb54는 제 헤더와 동일한 색입니다):

.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;
}

이제 완벽하게 해결되었습니다!

Hey @awesomerobot, 왜 다른 아이콘, 예를 들어 대화에서 이런 봉투 아이콘 같은 경우에도 요소를 검사하면 d-icon인데, 아래 CSS가 적용되지 않나요?

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

Screen Shot 2019-12-18 at 13.41.50

.d-header-icons는 구체적으로 오른쪽의 내비게이션을 가리킵니다.

PM 제목 아이콘의 경우 다음을 사용해야 합니다.

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

고정 및 잠금 토픽과 같은 다른 토픽 상태의 경우 다음을 사용할 수 있습니다.

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

SVG로 커스텀 아이콘을 추가했는데, CSS로 색상을 변경할 수 없습니다. 항상 검은색으로 표시됩니다. 투명도나 크기는 변경할 수 있지만, 색상은 절대 변경되지 않습니다.

위 예시들을 시도해 보았지만, 어느 것도 기대한 결과를 주지 않았습니다.

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

image

헤더 아이콘도 시도해 보았습니다.

제가 어디를 잘못하고 있나요?

아이콘에 SVG 코드 내에 인라인으로 색상이 정의되어 있나요? 아마 다음과 같은 형태일 것입니다:

Screen Shot 2020-01-06 at 11.09.59 AM

그렇다면 해당 값을 제거하거나 currentColor로 변경할 수 있습니다.

여러분,
문제가 있습니다:

  1. 메뉴를 클릭할 때 (이 부분은 문제없음)
  2. 마우스를 메뉴에서 떼어낼 때, 아이콘이 흰색 뒤에 가려지기 때문에 배경색과 마찬가지로 아이콘 색상도 변해야 합니다:

다음과 같이 시도해 보세요:

.drop-down-mode .d-header-icons .active .icon {
    background: black;
}

특정 아이콘의 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를 넣으세요 */
}

이것을 사용했는데 아주 잘 작동했습니다. @neounix님, 정말 유용한 정보를 주셔서 감사합니다.

Sentinelrv와 같은 상황입니다. header_primary를 흰색으로 변경하고 추천된 사용자 지정 CSS를 각 테마에 적용했지만, 확대경 아이콘과 햄버거 메뉴는 여전히 회색으로 남아 있습니다.

저도 햄버거/바 메뉴의 색상을 변경할 수 없습니다. 검색/찾기 아이콘은 변경되었는데, 웹 브라우저에서 요소를 검사하여 aforementioned 팁들과 그 이상의 방법을 모두 시도해 보았지만 (웹 개발자가 아니라서) 실패했습니다. 이 문제를 해결하신 분이 계신가요?

오른쪽 헤더 아이콘을 위한 CSS는 테마 또는 테마 컴포넌트의 common-css에서 다음과 같이 설정합니다:

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

사이드바 메뉴 모드에서 햄버거 아이콘을 위한 CSS:

.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> = 16진수 색상 코드, 색상 이름 또는 테마 색상 변수입니다. 아이콘 배경색을 변경하려면 background-color도 지정할 수 있습니다.

참고: 사이드바 대신 햄버거 드롭다운 모드를 사용하는 경우, 오른쪽 헤더 아이콘을 위한 첫 번째 스니펫에 햄버거 아이콘도 포함됩니다.