How do I make the value in the submit button transparent?
I have a submit button on a form and I am using a css class that sets a background image as a submit button. I need to provide a value for this submit button, but I don't want it to be displayed to the user. If I set the css color property to transparent, it works fine in my firefox 3.6. But the value is displayed at points 6 and 7. How can I solve this problem?
<div id="upldTempForm" class="pgcontent">
<form>
<div style="text-align:center;">
<input type="submit" name="create" value="" class="save" />
<input type="button" name="cancel" value="" class="cancel"/>
</div>
</form>
</div>
css
.pgcontent {
background-color:#ECECEC;
border:2px solid #E7E7E7;
margin:30px auto;
width:820px;
font-size:12px;
}
.save{
background-image:url("../images/save.gif");
background-repeat:no-repeat;
width:100px;
height:40px;
cursor:pointer;
background-color:transparent;
border:none;
}
.cancel{
background-image:url("../images/cancel.gif");
background-repeat:no-repeat;
width:110px;
height:40px;
cursor:pointer;
background-color:transparent;
border:none;
}
+2
a source to share
2 answers
Using text indentation will work.
Example:
INPUT[type=button], INPUT[type=submit]
{
font-weight: bold;
color: #000000;
text-indent: -99999px;
text-align: center;
background-color: Transparent;
background-image: url(../images/button.png);
background-repeat: no-repeat;
cursor: pointer;
}
Some little research has been done since nailxx's comment. IE is a transaction breaker (again).
For IE add:
font-size: 0;
display: block;
line-height: 0;
Decision
<div id="upldTempForm" class="pgcontent">
<form>
<div>
<input type="submit" name="create" value="Create" class="save" />
<input type="button" name="cancel" value="Cancel" class="cancel"/>
</div>
</form>
</div>
css
.pgcontent
{
background-color:#ECECEC;
border:2px solid #E7E7E7;
margin:30px auto;
width:820px;
font-size:12px;
text-align:center;
}
.save
{
background-image:url("../images/save.gif");
background-repeat:no-repeat;
width:100px;
height:40px;
cursor:pointer;
background-color:transparent;
border:none;
line-height: 100;
overflow: hidden;
}
.cancel
{
background-image:url("../images/cancel.gif");
background-repeat:no-repeat;
width:110px;
height:40px;
cursor:pointer;
background-color:transparent;
border:none;
line-height: 100;
overflow: hidden;
}
+10
a source to share