Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  82] [ 1]  / answers: 1 / hits: 15492  / 11 Years ago, sat, march 16, 2013, 12:00:00

so I have an image which i would like to overlay with an html button attribute like so:



here is a blank image
plain



i would like to overlay a button like so on the image
what



and then if the button is clicked have it then look like this
image



from what i can gather this could be done using CSS using {index-z} somehow, or possible with html5 canvas tag. and then to handle the actually button click with java script.
However i am not completely sure how to accomplish this (the handling of button click with javascript i do know). Could someone link to a tutorial on how to do this or give an explanation it would be greatly appreciated.



Note: the image itself is also an href / link if this changes how this should be done, additionally te image itself will be in a sort of gallery with around 50 similar images or so


More From » html

 Answers
18

You can use positioning to place the star button on top of the other image. Your image and button will need to be in a container with the position set to relative. Then you can set your star to be absolutely positioned, and that position will be relative to the container:



.image-container {
display: inline-block;
position: relative;
}

.star-button {
position: absolute;
right: 10px;
top: 10px;
}


<div class=image-container>
<img src=main image here>

<img class=star-button src=star image here>
</div>


Then you can handle the click of the image (or button, or a, or what have you) in your javascript.



JSFiddle


[#79556] Thursday, March 14, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
margaritakristinak

Total Points: 502
Total Questions: 127
Total Answers: 98

Location: England
Member since Mon, May 17, 2021
3 Years ago
;