I am trying to create this button without actually using the button tag. I created a button image and sliced it into three sections left-middle-right so when i add text to the link the image will expand depending on length. I am also using a hovering image – but when i try to apply this style to a button tag – the over feature doesn’t work – not sure if this is because a button tag doesn’t have a hover feature or not. But when i place this three piece image in a list format it works great displaying the hovered and un-hovered images of the ‘button’ but it doesn’t display properly on all web browsers.
Here is the list format style:
<ul class="glossyBtn">
<li class="newBtn">
<a style="margin-left: 12px"class="printRemove" href='<%:Url.Action("Close", "Close", new{caseId = Model.CaseId}) %>'><b><b class="bodyBtn">Close</b></b></a>
</li>
</ul>
This is the style when having the button tag but the hover css isn’t applied.
<ul class="glossyBtn">
<li class="newBtn">
<button class="noStyle" type="submit" value="save"> <a>
<b><b class="bodyBtn">Save</b></b></a></button>
</li>
</ul>
Here is the CSS:
.glossyBtn
{
position: relative;
padding: 5px 0 0 6px;
margin: 0 auto 0 auto;
height: 24px;
float: left;
list-style: none;
}
.glossyBtn li
{
float: left;
}
.glossyBtn li a, .glossyBtn li button, .glossyBtn li input a {
float: left;
color: #046fad;
text-decoration: none;
font-weight: bold;
font-size: 13px;
padding: 0 0 0 6px;
height: 24px;
line-height: 24px;
text-align: center;
cursor: pointer;
border-bottom: none;
}
.glossyBtn li a b, .glossyBtn li input a b {
height: 24px;
display: block;
padding: 0 8px 0 8px;
}
.glossyBtn li a b.bodyBtn, .glossyBtn li input a b.bodyBtn
{
height: 24px;
display: block;
}
.glossyBtn li.newBtn a, .glossyBtn li.newBtn input a
{
color: #046fad;
background: url('images/iconPlace.png') no-repeat 0 0;
}
.glossyBtn li.newBtn a b, .glossyBtn li.newBtn input a b {
color: #046fad;
background: url('images/endBtn.png') no-repeat right 0;
}
.glossyBtn li.newBtn a b.bodyBtn, .glossyBtn li.newBtn input a b.bodyBtn
{
background: url('images/bodyBtn.png') repeat-x;
}
.glossyBtn li a:hover, .glossyBtn li button a:hover {
background: url('images/iconPlace.png') no-repeat 0 -24px;
}
.glossyBtn li a:hover b, .glossyBtn li button a:hover b {
background: url('images/endBtn.png') no-repeat right -24px;
}
.glossyBtn li a:hover b.bodyBtn, .glossyBtn li button a:hover b.bodyBtn
{
background: url('images/bodyBtn.png') repeat-x 0 -24px;
}
Any suggestions or alternatives to what i am trying to do would be appreciated. Thanks!
Unless I misunderstood your question, you don’t really need the three sections to get an “expanding button”. Leave the width alone and you get this automatically. Take a look: http://jsfiddle.net/HrCR8/3/
I should credit this particular button to Chad Mazzolla and his collection of styles for creating buttons. You can find them here http://hellohappy.org/css3-buttons/