CSS: option did not get style on PC, why?

Hello, Why option did get only the font styles, and nothing else? https://codepen.io/lanszelot/pen/BaboBxB On tablet and phone get all the styles, only PC did not. I do not understand why.
33 Replies
clevermissfox
clevermissfox12mo ago
There is only option elements showing. Select is the parent element, so it’s font properties are inherited to its children, option. You have the same font size and font weight on both select and option , which is unnecessary. Option(s) get those properties inherited. What else are you expecting to see on the page ?
MarkBoots
MarkBoots12mo ago
form ui elements work different on different browsers. unfortunately there is no uniform way to style them all in the same way and not everything is stylable. If you want full control, you'll have to create them from scratch for example, these are the only styles you can apply to the options for chromium browers (such as chrome and edge) https://blogs.windows.com/msedgedev/2022/05/05/styling-select-elements-for-real/
lanszelot
lanszelotOP12mo ago
Thank you so much
MarkBoots
MarkBoots12mo ago
they are working on a <selectmenu> element which you have more control of, but it's unknown when that's ready for production https://open-ui.org/prototypes/selectmenu/
lanszelot
lanszelotOP12mo ago
But same browser, in mobile or tablet why working well?
MarkBoots
MarkBoots12mo ago
there is still a difference in os, which can slighty differ
lanszelot
lanszelotOP12mo ago
same os
MarkBoots
MarkBoots12mo ago
not same os. one is desktop, one is mobile
lanszelot
lanszelotOP12mo ago
F12 in chrome browser, and change to mobile view or tablet it is working well, but when I change PC view it is not working second one is PC view, the first one is tablet same OS same browser, same everything, only F12
MarkBoots
MarkBoots12mo ago
not sure about that. i think it is trying to emulate the mobile select ui (which is outside of the browser window) check on a phone or tablet to see the real result
lanszelot
lanszelotOP12mo ago
I found this, here is working well same as I did but mine not working:
lanszelot
lanszelotOP12mo ago
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
lanszelot
lanszelotOP12mo ago
same browser, mine not working, W3 working
MarkBoots
MarkBoots12mo ago
that is not a <select> element with <options>. that select is set to display none, and a custom build one takes it over
lanszelot
lanszelotOP12mo ago
it is not inherit the properties. You could delete those lines from my codepen, and you can see it is not working.
MarkBoots
MarkBoots12mo ago
clevermissfox
clevermissfox12mo ago
Select is an options parent. It inherits its font values from it. You can’t style the drop-down in most browsers, but if you choose any option as the shown value when the drop-down closes , it’s inherited. Like here I’ve only applied a font-size to the select and if you choose any one of the options, that font size is inherited. https://codepen.io/Miss-Fox/pen/mdoePvY
Miss Fox
CodePen
mdoePvY
...
lanszelot
lanszelotOP12mo ago
yes, you have right. it is confused me, because there is the options ones too
clevermissfox
clevermissfox12mo ago
So no reason to put the same font styles on the option selector
lanszelot
lanszelotOP12mo ago
please use mine, and you will see, that is not working here, I commented those, and not inherit
lanszelot
lanszelotOP12mo ago
it is not bold
clevermissfox
clevermissfox12mo ago
Different browsers are going to handle form elements differently as Mark said. This is what I see on mobile , iPhone (don’t know what iOS version right now but latest probably) and chrome I see bold on my side. Idk what font family you’re using but you could try to declare font-weight:700; sometimes it’ll skip to the next weight and if that weight isn’t defined in the font family it won’t look bold so you explicitly set your headings and strong tags to font-weight:700;
MarkBoots
MarkBoots12mo ago
Dont focus to much on styling for phone and tablet. The phone ui will take it over anyway. Here in chrome on android.
lanszelot
lanszelotOP12mo ago
here is on the PC
clevermissfox
clevermissfox12mo ago
I cannot wait for the selectmenu element On someone else’s PC it won’t look like that. If you are really concerned about it create your own custom drop-down element
MarkBoots
MarkBoots12mo ago
yea, but apparenty you can already test it with flags, but not sure if also on phone
clevermissfox
clevermissfox12mo ago
But for it to be supported and be able to use in production !
MarkBoots
MarkBoots12mo ago
will look into it soon. not sure how the phone ui's will handle it
lanszelot
lanszelotOP12mo ago
on phone there is "desktop mode" it have to work like pc in Chrome, right top 3 dots dropdown menu -> Desktop site :tick on
MarkBoots
MarkBoots12mo ago
again, if you want consistant beheaviour, you'll need to build it yourself from scratch (like w3schools did)
lanszelot
lanszelotOP12mo ago
yes, thank you.
clevermissfox
clevermissfox12mo ago
Yes but it still has to take everything into account. Just like your dev tools responsive mode doesn’t simulate an actual phone environment , desktop mode doesn’t simulate an actual PC environment
Want results from more Discord servers?
Add your server