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

Dropdown is not vertically aligned with <a> in <nav> #498

Open
carlreinke opened this issue Mar 19, 2024 · 2 comments
Open

Dropdown is not vertically aligned with <a> in <nav> #498

carlreinke opened this issue Mar 19, 2024 · 2 comments

Comments

@carlreinke
Copy link

carlreinke commented Mar 19, 2024

Describe the issue

A dropdown in a <nav> is slightly misaligned with an anchor in the nav. The text of the dropdown is also slightly misaligned even after aligning the outlines.

Current Behavior

image

Expected Behavior

image or image

Reproduction URL

https://picocss.com/docs/nav#dropdowns (I added style="outline: 1px solid red;" on the <a> and <summary>.)

Environment

Firefox on Windows 10

@carlreinke carlreinke changed the title Dropdown is not vertically aligned in <nav> Dropdown is not vertically aligned with <a> in <nav> Mar 19, 2024
@FireIsGood
Copy link
Contributor

This seems to be caused by the height being set manually but calculating incorrectly. The current version as shown in the reproduction URL does not account for the border decreasing the size of the content box or something like that.

Here's one of the places the height is set:

nav details.dropdown summary:not([role]) {
    height: calc(1rem * var(--pico-line-height) + var(--pico-nav-link-spacing-vertical) * 2);
    padding: calc(var(--pico-nav-link-spacing-vertical) - var(--pico-border-width) * 2) var(--pico-nav-link-spacing-horizontal);
}

image
As seen in the original post

We can note that the height is set manually and accounts for both 1rem times the line height to get the height of a root element line, then adds the padding again.

I'm not sure the exact reason as there seems to be a bit of negative margins or other shenanigans used on the nav elements I haven't taken a peek at, but adding this seems to be a quick fix on this specific case:

nav details.dropdown summary:not([role]) {
    height: calc(1rem * var(--pico-line-height) + var(--pico-nav-link-spacing-vertical) * 2 - 2 * var(--pico-border-width));
}

image

I'm not able to look into this further myself, so I hope this helps anyone looking into this later!

@ckemere
Copy link

ckemere commented May 1, 2024

This issue hasn't seen much updates, but I can confirm that the weird rendering is only present in Firefox, rather than Chrome (and Safari).

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

No branches or pull requests

3 participants