Skip to content
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

Fix header component's reliance on markup whitespace #884

Merged
merged 4 commits into from
Jul 11, 2018

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Jul 11, 2018

display: inline-block is sensitive to whitespace, so if there are characters in between two divs
that will be output when they are rendered.

This means when columns are exactly 33.3% and 66.6% to sit alongside each other,
the whitespace that is output misaligns the columns forcing them onto a new line.

Using floats is similar to how our grid system works, but requires a clearfix on the parent container,
so that the component does not collapse.

I have tested this cross browser and also did a before and after at different viewports to check the behaviour is consistent.

That said this change still makes me nervous, so appreciate reviewers scrutiny 😄

Fixes #828

https://trello.com/c/bKTTsJzo/1194-service-name-falls-below-govuk-in-header-when-there-is-whitespace-between-the-two-divs

`display: inline-block` is sensitive to whitespace, so if there are characters in between two divs
that will be output when they are rendered.

This means when columns are exactly 33.3% and 66.6% to sit alongside each other,
the whitespace that is output misaligns the columns forcing them onto a new line.

Using floats is similar to how our grid system works, but requires a clearfix on the parent container,
so that the component does not collapse.
This also adds whitespace between the 'content' div and it's sibiling column,
which is enabled by the work to make this CSS use floats instead of `display: inline-block`
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-884 July 11, 2018 10:32 Inactive
@NickColley NickColley changed the title WIP: Fix header inline block markup dependence Fix header component's reliance on markup whitespace Jul 11, 2018
Copy link
Contributor

@alex-ju alex-ju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested cross browser as part of alphagov/govuk_publishing_components#408

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@NickColley NickColley merged commit 3c6e9d3 into master Jul 11, 2018
@36degrees 36degrees added this to the v1.1.0 milestone Jul 11, 2018
@NickColley NickColley deleted the fix-header-inline-block-markup-dependence branch July 11, 2018 13:09
@NickColley NickColley mentioned this pull request Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Service name falls below GOV.UK in header when there is whitespace between the two divs
4 participants