Update - Adding a 3rd State
Someone asked if it would be possible to add a 3rd state for the button for when the button is being clicked. You can do that with the :active pseudo-class on the anchor tag.
You would just need a few changes. First, you need to add a third button to your image:
example.png
Then, the height attribute for the regular button in your CSS needs to be 1/3 of the actual height of the image file. So, change this:
PHP Code:
a.add_to_cart_btn {
background-image: url(<?php print sc_img('btn_add_to_cart','dyn') ?>);
width: <?php print sc_img('btn_add_to_cart','width') ?>px;
height: <?php print sc_img('btn_add_to_cart','height') / 2 ?>px;
display: inline-block;
<?php if ($SC['browser']['browser'] == 'fx' && $SC['browser']['maj_ver'] < 3.0): ?>
display:-moz-inline-box;
<?php endif; ?>
margin-top: 2px;
}
to this:
PHP Code:
a.add_to_cart_btn {
background-image: url(<?php print sc_img('btn_add_to_cart','dyn') ?>);
width: <?php print sc_img('btn_add_to_cart','width') ?>px;
height: <?php print sc_img('btn_add_to_cart','height') / 3 ?>px;
display: inline-block;
<?php if ($SC['browser']['browser'] == 'fx' && $SC['browser']['maj_ver'] < 3.0): ?>
display:-moz-inline-box;
<?php endif; ?>
margin-top: 2px;
}
Then, change this:
PHP Code:
a.add_to_cart_btn:hover {
background-position: 0 -<?php print sc_img('btn_add_to_cart','height') / 2 ?>px;
}
To this:
PHP Code:
a.add_to_cart_btn:hover {
background-position: 0 -<?php print sc_img('btn_add_to_cart','height') / 3 ?>px;
}
and finally, add a 3rd block of CSS after that for the active state:
PHP Code:
a.add_to_cart_btn:active {
background-position: 0 -<?php print sc_img('btn_add_to_cart','height')/3*2 ?>px;
}
That will show the ugly green button on hover, and the ugly yellow button only while the button is being clicked.