Colorizing the Cart and Lists buttons

The OPAC’s Cart and Lists buttons are an unusual construction. Their appearance is the result of a rather convoluted combination of CSS and HTML designed to give nice anti-aliased, rounded corners and flexibility when the text is resized.  Try increasing the font size in your browser (Ctrl +).


The technique to create these buttons was adapted from Scalable CSS Buttons Using PNG and Background Colors.  If you’re interested in understanding the real nuts and bolts of the technique I suggest you read through that article. I’m going to cover just the details we need to look at for customizing the default appearance in Koha. [Edit: The link no longer works, sorry.]

There are several options we need to cover when changing the buttons’ appearance:

  1. The link and link hover color
  2. The button background-color (default and hover)
  3. The button border

The Cart and Lists buttons each have their own ID in the HTML for reference in the CSS: #cartmenulink and #listsmenulink. Let’s look at the Lists button for simplicity’s sake.

1. The link color

The link color is the most straightforward one: Target the A element with the #listsmenulink ID:

[sourcecode language=”CSS”] a#listsmenulink { color: #E5CCE6; }
a#listsmenulink:hover { color: #FF99FF; }

2. The button background-color (default and hover)

The buttons have both a default background color and a hover background color. Set them by targeting the #listsmenulink ID:

[sourcecode language=”CSS”]

#listsmenulink { background-color : #6600CC; }
#listsmenulink:hover { background-color : #9900CC; }


If we’re just changing background colors, and not images, on the button, how is it possible that we get a nice gradient? The answer is in this part of the default CSS:

[sourcecode language=”CSS”]

#listsmenulink[class] {
background-image : url(../../images/button-background-gradient.png);
background-position : left top;


That’s a PNG file with alpha transparency. It overlays the solid background color and softens it with a gradient. If you like the gradient you can leave this part of the CSS without overriding it in your custom stylesheet. It will work with whatever background color you specify. If you want to turn it off to have a solid-color button, use this:

[sourcecode language=”CSS”]

#listsmenulink[class] {
background-image: none;


3. The button border

Changing the button border is the trickiest step because it requires an image editor. The button border consists of a single background-image:


How the button would appear if the border image had transparent corners

How the button would appear if the border image had transparent corners

The image gives the button its border color. The center of the image is transparent. The corners are opaque, colored to match the blue of the default background of the search bar. The corners have to be opaque because they have to mask the square corners of the HTML element behind them.

Changing the background color means the corners no longer match what is behind them

Changing the background color means the corners no longer match what is behind them

The fact that the corners are colored to match the default background means that if you try to change that background color your buttons will no longer match.

At the moment the only solution for those wishing to make changes to the button background is to recreate it from scratch. I’d like to share the source files I’m using so that in the future it’s easier for Koha users to make this change themselves. I use Photoshop 7 much of the time (yes I know it’s old), so I’m offering that version. I also recreated the graphic in Fireworks MX (again, old) and Inkscape .046 (yay, up to date!).

Photoshop 7 koha3-opac-button-background.psd 29.4K
Fireworks MX koha3-opac-button-background.png 39.5K
Inkscape 0.46 koha3-opac-button-background.svg 5.2K

Whatever program you use to edit these files, there are two basic steps to achieve the right look:

  1. Edit the stroke of the button shape (the border color).
  2. Change the color of the opaque corners.

Our edited button background image gives us corners that blend perfectly with our custom background color.

After your file is edited to your satisfaction the next step is to export it in a web-friendly format:

  • If you’re using Photoshop use File > Save for Web and choose PNG-24 with the Transparency option checked.
  • In Fireworks, your Optimize setting should be PNG32 with the transparent matte option chosen.
  • In Inkscape, use the Export Bitmap option to export the Drawing only. In my tests Inkscape exported the 32-bit version (the version with alpha transparency) by default.

What About Internet Explorer 6?

Users of Internet Explorer 6 will see a solid-color button with square corners.

Users of Internet Explorer 6 will see a solid-color button with square corners.

One major downside of this method of styling the buttons is that it doesn’t work properly in Internet Explorer 6. IE6 doesn’t support PNG files with alpha transparency. The good news is that users of IE6 will still get a usable button. The bad news is that it won’t be very pretty.

Options Going Forward

If we’re already excluding users of Internet Explorer from the rounded button experience, why not use pure-CSS rounded corners? We could eliminate all the time and effort demonstrated in this article with some simple [if proprietary] CSS. Something like this:

[sourcecode language=”CSS”] #cartmenulink,#listsmenulink {
color: #336600;
padding: .7em .9em .7em .8em;
margin: .5em .5em .5em 1.5em;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;

#cartmenulink {
border:1px solid #336699;
background: #93d869 url(“../../images/cart-button-background.png”) top left repeat-x;
#listsmenulink {
border:1px solid #006699;
background: #9FBFFF url(“../../images/lists-button-background.png”) top left repeat-x;

This works fairly well in Firefox, Safari, and Chrome. Unfortunately, it fails not only in Internet Explorer 6, 7, and 8, but all versions of Opera too. For the time being, our more-complex process gives the desired result to a wider audience.

Using *-border-radius to style rounded corners

Using *-border-radius to style rounded corners. Click to view full-size.

4 thoughts on “Colorizing the Cart and Lists buttons

  1. Mike McCormack

    We are using IE6 in house and when we hover over either the Links or Cart buttons part of the bottom of the screen disappears. If you are on the search page then everything under the banner clears and if you have a results set and you hover then the last few results and the right had scrollbar will disappear.

    Would you have any idea how to get around this as we won’t be changing IE6 for a while yet.



Leave a Reply

Your email address will not be published.