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 scrolling of code examples #717

Merged
merged 2 commits into from
Mar 13, 2019
Merged

Conversation

simurai
Copy link
Contributor

@simurai simurai commented Mar 11, 2019

This fixes #708 where some code examples in the docs show a scrollbar.

Screen Shot 2019-03-11 at 8 07 50 PM

The problem seems to be that if a code example uses margin, it doesn't get included when calculating the height for the <iframe>. For example the .tabnav has a height of 37px with a bottom-margin of 15px, but the height of the <iframe> is only 37px, causing the rest to scroll.

Adding overflow: auto to a parent element of the code example seems to fix it.

Preview

Alternatives

We could add any other property that creates a new block formatting context. Not sure if overflow: auto has side effects? 🤔 display: flow-root would be most appropriate, but browser support isn't that great yet.

prettier/prettier
@whytrall
Copy link

Alternative idea: calculate height using something like height = height + margin. I'm not sure if it would work here, but why not ¯\_(ツ)_/¯

@shawnbot
Copy link
Contributor

Ugh. @thetrall As much as I'd prefer not to have to calculate margins, I agree that that's probably the right thing to do here. Either that, or cancel out the margins on the rendered HTML? 😬

@emplums
Copy link
Contributor

emplums commented Mar 11, 2019

@shawnbot Do you have any issues with just setting overflow: auto? That seems like the most simple fix to this issue, unless you foresee any weirdness coming from that?

@shawnbot
Copy link
Contributor

@emplums I am worried that overflow: auto is just a band-aid, but the scrollbars are pretty bad, so let's ship this in 12.1.2. Thanks, @simurai! ❤️

@simurai simurai changed the base branch from master to release-12.1.2 March 12, 2019 04:18
@simurai simurai added this to Release backlog in 📦 Primer CSS release tracking via automation Mar 12, 2019
@simurai simurai moved this from Release backlog to v12.2.0 in 📦 Primer CSS release tracking Mar 12, 2019
@simurai simurai closed this Mar 12, 2019
📦 Primer CSS release tracking automation moved this from v12.2.0 to 💜 Done Mar 12, 2019
@simurai simurai changed the base branch from release-12.1.2 to release-12.2.0 March 12, 2019 08:27
@simurai simurai reopened this Mar 12, 2019
@simurai simurai moved this from 💜 Done to v12.2.0 in 📦 Primer CSS release tracking Mar 12, 2019
@simurai simurai mentioned this pull request Mar 12, 2019
10 tasks
Copy link
Contributor

@shawnbot shawnbot left a comment

Choose a reason for hiding this comment

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

I tested this on the branch deployment and it looks great. Ship it! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants