How to align jQuery UI selectmenu with buttons?
I've been struggling with this for a while (I'm not very good with jQuery UI).
I am trying to implement jQuery UI that has selectmenu next to some regular... For some reason I can't figure out the selectmenu is not aligned correctly; on the page higher than on the buttons.
This is how it looks:
I'm not sure if this is a bug or not, it seems very wrong to me. I struggled for a long time but could not understand.
The markup is really very simple, so I don't think it's very useful to include it here. But it's all here: http://jsbin.com/afixij/10/edit?html,css,js,output . Expand the output to see all three elements (selectmenu and Foo and Bar buttons) on one line.
source to share
You can simply apply vertical-align:middle
to a dropdown of spacing to align the buttons with the dropdown correctly.
#speed-button{
vertical-align : middle;
}
It looks like there is no way to provide a custom class name for the selected menu widget (which is bad if it does), since applying the rule to the class would be much better. You also can: -
Apply class name for select
and in css provide general rule for any .menu-button
s
.menu-button + .ui-selectmenu-button{
vertical-align : middle;
}
source to share
To expand on the marked answer, there is a way to get the jquery object that the selectmenu creates. Make sure you initialize selectmenu first, or it won't work.
$("#speed").selectmenu();
$("#speed").selectmenu("widget").addClass("fixAnnoyingSelectAlignmentClass");
CSS
.fixAnnoyingSelectAlignmentClass
{
vertical-align: middle;
}
source to share