Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - position button inside image

I have div that contains an image, I need to place a button inside the image to around the top right corner of the image, when I do this

#button_id{
position: relative;
    left: 270px;
    top: 30px;
}

What this is doing is making the button image be placed somewhere else, it moves the image left to the right and down, but the now the button is click-able in bar from where it was originally placed to the far right of the div. When I try this

#button_id{
     position: relative;
     float: right; padding: 0px -40px -15px;
}

it moves the button to the right but it won't move it down.

Note: the button is inside the div, without the css it is placed on top of the image in the center

like image 494
Kevin Avatar asked Jun 27 '12 15:06

Kevin


People also ask

How do I put a button inside a picture?

You should give the div containing the image a position:relative and your button that is contained within that div a position:absolute . That will position the button relative to the container div. Show activity on this post. Take a look this example below: an image with previous and next button over it.

Can I use IMG inside button?

You can include an <img> element inside your <button> element to display the image on the button.


1 Answers

You should give the div containing the image a position:relative and your button that is contained within that div a position:absolute. That will position the button relative to the container div.

like image 114
Nick Avatar answered Oct 14 '22 03:10

Nick