Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Button element 'font-family' diverges from a[role=button] or a[class=button] on Chrome #36

Closed
GuilhermeRossato opened this issue Aug 15, 2019 · 6 comments · Fixed by #39

Comments

@GuilhermeRossato
Copy link

GuilhermeRossato commented Aug 15, 2019

There's a bug when switching from a <a> element to a <button> element caused by the button element not having font-family defined (defaults to Arial in my browser).

Browser: Google Chrome v76.0.3809.100
OS: Windows 10 OS Version 1803

To reproduce you just have to compare css of an element of type:

<a class="button primary">Submit</a>

With the same as a button:

<button class="button primary" type="submit">Register</button>

The element's css has a 'user agent stylesheet' that defines its font as the following:

font: 400 13.3333px Arial;

The element's css has its font defined at body normally, this is where the divergence comes from.

This can be even observed at this demo's link.

Proposed fix (also including font-size and letter-spacing, which is also necessary)

.button {
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    font-family: var(--font-family);
    font-size: var(--font-size);
    letter-spacing: .01em;
}

Disclaimer: I have not checked other browsers's behaviour.

@GuilhermeRossato GuilhermeRossato changed the title Button != a[role=button] button element font-family diverges from a[role=button] or a[class=button] on Chrome Aug 15, 2019
@GuilhermeRossato GuilhermeRossato changed the title button element font-family diverges from a[role=button] or a[class=button] on Chrome Button element font-family diverges from a[role=button] or a[class=button] on Chrome Aug 15, 2019
@GuilhermeRossato GuilhermeRossato changed the title Button element font-family diverges from a[role=button] or a[class=button] on Chrome Button element 'font-family' diverges from a[role=button] or a[class=button] on Chrome Aug 15, 2019
@jenil
Copy link
Owner

jenil commented Aug 16, 2019

🤔
Can you send me a video of this? I can't reproduce this on a Macbook so might be worth seeing this in action.

@yne
Copy link
Contributor

yne commented Sep 13, 2019

Confirmed from Chromium on Linux:
image

Chromium does not forward body css properties to the <button> , so the 3 following rules are missing on any <button>.

letter-spacing: 0.01em;
font-weight: 400;
font-family: var(--font-family);

I would rather suggest to use unset or inherit (like normalize) so we could would avoid duplicating rules from the body.

Alternate solution:

Just include normalize.css ;)

<link rel="stylesheet" href="http://unpkg.com/normalize.css">

@jenil
Copy link
Owner

jenil commented Sep 14, 2019

I see, can someone make a tested PR for this?

@yne
Copy link
Contributor

yne commented Sep 14, 2019

I'm on it

@jenil jenil closed this as completed in #39 Sep 14, 2019
jenil added a commit that referenced this issue Sep 14, 2019
Add .dropdown class (#29) and fix #36
@jenil
Copy link
Owner

jenil commented Sep 14, 2019

Ships in v0.7.0

@boazblake
Copy link

not sure if this is related to the bug I am seeing in safari, but if you check the chota.css homepage and hover over the links that have button classes, the hover animation is broken.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants