how to show delete button in top right corner of I

2020-05-18 11:49发布

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

标签: jquery html
7条回答
狗以群分
2楼-- · 2020-05-18 11:55

You might try this:

<div style="position:relative; width:'mainimagewidth'">
main image<img src="" />
<span style="position:absolute; top:0; right:0;">ximage<img src="" /></span>
</div>
查看更多
霸刀☆藐视天下
3楼-- · 2020-05-18 11:56

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/

查看更多
看我几分像从前
4楼-- · 2020-05-18 12:04

I have coded one up for you http://jsfiddle.net/PPN7Q/

You need to wrap the image in a DIV

<div class="thumbnail">
<img src="http://96pix.com/images/renee-v.jpg" />
 <a href="">Delete</a>
</div>

and apply the following CSS rules

.thumbnail {
width:50px;
height:50px;
position:relative;
}

.thumbnail img {
max-width:100%;
max-height:100%;
}

.thumbnail a {
display:block;
width:10px;
height:10px;
position:absolute;
top:3px;
right:3px;
background:#c00;
overflow:hidden;
text-indent:-9999px;
}
查看更多
爷、活的狠高调
5楼-- · 2020-05-18 12:08
<div style=" float: right;margin-left: 289px;position: absolute;">*</div>
<img src="score.png" width="300" height="300" />

Please try this. It might help.

查看更多
再贱就再见
6楼-- · 2020-05-18 12:09

Try something like

<div style="position: relative">
    <img src="http://www.google.co.in/images/srpr/logo4w.png" />
    <img src="http://wecision.com/enterprise/images/icons/closeIcon.png" style="position: absolute; top: 4px; right: 5px"/>
</div>

Demo: Fiddle

查看更多
混吃等死
7楼-- · 2020-05-18 12:09

In my opinion you can just set style="position:absolute;top:0px;right:0px;" for RemoveButton.ico and style="position:relative;" for div with img

查看更多
登录 后发表回答