Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show delete button in top right corner of Image?

Tags:

html

jquery

i would like to show delete button at top right corner to image? how could i achieve this?

my html is like this :-

main image :

<img id="' + id + '" src="../Images/DefaultPhotoMale.png" class="' + item + '" width="40" height="40" alt="image" title="' + projectTitle + '" style="cursor:pointer" /> 

x button image to display in top-right of above image

  • '<img id="' + item.Soid + '" src="../Images/RemoveButton.ico" style="display:none" title="Remove Specialization" />

No background image set please, i need click event for that delete button something like this :

enter image description here

like image 201
Nestor C Avatar asked Mar 07 '13 13:03

Nestor C


People also ask

How do you put a button in the top right corner in CSS?

Just add position:absolute; top:0; right:0; to the CSS for your button.

How do you put a button under a picture?

just wrap your image inside a div and your button inside another div, so the button will be cascaded directly below the image then you can style your button's div as you like for example make the button centered below the image as in the sample provided.


1 Answers

Usual approach with position: relative and position: absolute.

HTML:

<div class="img-wrap">     <span class="close">&times;</span>     <img src="http://lorempixel.com/100/80"> </div> 

CSS:

.img-wrap {     position: relative;     ... } .img-wrap .close {     position: absolute;     top: 2px;     right: 2px;     z-index: 100;     ... } 

Extended demo (+ JS interaction) http://jsfiddle.net/yHNEv/

like image 110
dfsq Avatar answered Sep 24 '22 16:09

dfsq