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

Tweak the default alignment of input[type="range"] #7570

Open
tomayac opened this issue Feb 3, 2022 · 4 comments
Open

Tweak the default alignment of input[type="range"] #7570

tomayac opened this issue Feb 3, 2022 · 4 comments
Labels
needs implementer interest Moving the issue forward requires implementers to express interest topic: forms topic: rendering

Comments

@tomayac
Copy link

tomayac commented Feb 3, 2022

The alignment of input[type="range"] looks a bit off by default, and to make it look nicer, one has to apply vertical-align: middle to the hosting element:

Screen Shot 2022-02-03 at 10 12 38

Could maybe the default alignment of input[type="range"] be changed, so that authors don't have to make this tweak in CSS?

(Live demo courtesy of @simevidas. Issue filed by encouragement from @zcorpan.)

@Stranicola97
Copy link

Hello
is this request still open?

Nicola

@zcorpan
Copy link
Member

zcorpan commented Feb 18, 2022

So both are inline-blocks that are baseline-aligned, but the range control has no text in it.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/10060

Interestingly, Firefox has different alignment compared to Chrome and Safari for empty buttons. I'm not sure if the alignment of empty buttons needs some magic that is not currently defined in the spec (https://html.spec.whatwg.org/multipage/rendering.html#button-layout-2)...

I don't think it's possible to switch all controls to vertical-align: middle due to web compat, and I don't know if there's any other solution to aligning form controls to make it "look nicer" and still work for any size of button, for example.

@simevidas
Copy link

Could the meaning of baseline alignment for range inputs be changed so that the visible track directly sits on the baseline? Like so:

152313431-b56cc2b5-58e5-426b-82c0-f243bb606f44

That might even be the ideal vertical alignment for this control.

@zcorpan
Copy link
Member

zcorpan commented Feb 18, 2022

I suppose it could, however...

When looking at all widgets, I noticed that meter and progress are similar, but they have a default UA style of vertical-align: -0.2em! input type=range doesn't.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/10061

That seems like a possible fix? At least in Chrome and Safari it looks like an improvement, though it might not be perfectly aligned. The meter and progress elements also don't have the bottom of the rail touching the text baseline (but the appearance differs between browsers).

cc @josepharhar @mfreed7 this issue may be relevant for web-platform-tests/interop#11

@zcorpan zcorpan added the needs implementer interest Moving the issue forward requires implementers to express interest label Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs implementer interest Moving the issue forward requires implementers to express interest topic: forms topic: rendering
Development

No branches or pull requests

4 participants