I'm trying to replace the submit button with an image by defining it in a class="myButton"
and change the styles in CSS. the myButton:active
doesn't seem to work when being clicked.
Here is my CSS:
.myButton{
background:url(./images/but.png) no-repeat;
cursor:pointer;
border:none;
width:100px;
height:100px;
}
myButton:active {
background:url(./images/but2.png) no-repeat;
}
HTML code:
<input class="myButton" type="submit" value="">
Complete HTML/CSS Course 2022 To use image as a link in HTML, use the <img> tag as well as the <a> tag with the href attribute. The <img> tag is for using an image in a web page and the <a> tag is for adding a link. Under the image tag src attribute, add the URL of the image.
The image buttons in the HTML document can be created by using the type attribute of an <input> element. Image buttons also perform the same function as submit buttons, but the only difference between them is that you can keep the image of your choice as a button.
Button with an ImageYou can include an <img> element inside your <button> element to display the image on the button. You can still add text to the button, resulting in a combination of image and text.
Check this link . You were missing .
before myButton
. It was a small error. :)
.myButton{
background:url(./images/but.png) no-repeat;
cursor:pointer;
border:none;
width:100px;
height:100px;
}
.myButton:active /* use Dot here */
{
background:url(./images/but2.png) no-repeat;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With