I have a select box that I want to be aligned to the right, but I want to keep the options dropdown aligned to the left. Like so:
<select>
<option>item</option>
</select>
And the CSS:
select { direction: rtl; }
option { direction: ltr; }
But setting the direction of the select tag also sets the direction of the select dropdown menu. See here
Is this even possible? I know that I could, as an alternative, build a custom select functionality with js, but I'd like to keep it simple if I can.
direction: rtl;
is not exactly text alignment. Or to be precise text alignment is a side effect of direction. Note that direction also affects position of the dropdown arrow in your setup.
Conventional browsers do not allow you to style select element (it looks significantly different on different platforms, especially mobiles).
In Sciter you can style <select>
parts individually as select components are normal DOM elements there:
select > caption { text-align:right; }
select > button { ... }
select > popup > option { text-align:left; }
I've made it possible as Sciter is designed specifically for desktop UI and <select>
styling is a must there.
As a solution for plain web pages I would suggest to use <select>
substitutes like http://getbootstrap.com/components/#btn-dropdowns