-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only underline logo on hover (with custom colours) #926
Conversation
src/components/header/_header.scss
Outdated
border-bottom-color: currentColor; | ||
margin-bottom: -1px; // Negate transparent bottom border | ||
border-bottom: 1px solid currentColor; | ||
@include govuk-if-ie8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you include a comment that explains why the ie8 code is needed? the info in the PR is very good
src/components/header/_header.scss
Outdated
@@ -108,6 +108,8 @@ | |||
&:active { | |||
margin-bottom: -1px; // Negate transparent bottom border | |||
border-bottom: 1px solid currentColor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, I think that border's default colour is currentColor
which could mean changing this statement to border-bottom: 1px solid
may remove the need for the conditional IE8 logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion – that seems to work well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice attention to detail. 👍
I have a comment on a potential simpler approach, that is non-blocking.
Because all borders will become text colour when a user overrides colour in their browser, the transparent border will become always visible. By only applying the border on hover we avoid this which means we get the correct behaviour even when colours are customised. The layout is not affected because we offset the additional border with a negative margin. Removing any border-color attribute means that we'll use the currentColor for the border - making this explicit results in IE8 ignoring the rule because it doesn't understand the currentColor variable.
3a500b7
to
6ce51bf
Compare
@NickColley would you mind taking another look? |
👍 |
Because all borders will become text colour when a user overrides colour in their browser, the transparent border will become always visible.
By only applying the border on hover we avoid this which means we get the correct behaviour even when colours are customised. The layout is not affected because we offset the additional border with a negative margin.
We do however have to add an additional rule for IE8 which does not support customColor and so ignores the rule entirely - which meant it had no border before. This would be fine, except the negative margin does kicks in on hover, which means without a border the header would shrink by 1px on hover in IE8.
Before
After