How to Style the Trigger Button Image of a jQuery Datehandler
Posted by fbloggs in CSS, jQueryThe jQuery UI datepicker object has lots of CSS style settings you can customize. Most of these apply to the calendar that appears, though. In a recent project I was using the standard image shown on the datepicker examples page for the trigger button. This appears when you set the button image properties, like this:
buttonImage: 'images/calendar.gif', buttonImageOnly: true
However, the image didn’t line up vertically with my input field, and it was squished too close to the input field’s right border.
Here’s the problem:

Misaligned and poorly spaced datepicker trigger image
So I needed to style it. I couldn’t find anything in the documentation or the style sheets that told me how to do this, so I looked at the generated HTML with FireFox debugger and discovered the button uses a class of ui-datepicker-trigger . To correct the problem, I created the style directly in the page, following the included jQuery style sheets. Here’s the selector:
<style>
/* This is the style for the trigger icon. The margin-bottom value causes the icon to shift down to center it. */
.ui-datepicker-trigger {
margin-left:5px;
margin-top: 8px;
margin-bottom: -3px;
}
</style>
The margin-left value put some white space between the right edge of the input field and the image, while the margin-bottom value of -3 shifted the icon down slightly. The margin-top value caused both the input field and the icon to shift down 8 pixels, providing white space between the datepicker and the stuff above it. Here’s the result:

After ui-datepicker-trigger style applied
Entries (RSS)
Update: this only works in FireFox. In IE, the button does not align vertically.
[...] under: CSS, jQuery — Tags: CSS, JavaScript, jQuery — fbloggs @ 11:30 am Please read this post at my new hosted site (July 17, [...]
Thanks! This worked for me both in IE 6 and Firefox 3.01.
Thanks – worked great for me!
Saved the day, thnks.