2013-03-07 22 views
16

Chciałbym pokazać przycisk usuwania w prawym górnym rogu obrazu? Jak mogę to osiągnąć?jak wyświetlić przycisk usuwania w prawym górnym rogu obrazu?

mój html jest tak: -

główne zdjęcie:

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

x przycisk obraz wyświetlany w prawym górnym rogu obrazek

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

Nie mam ustawionego obrazu tła, potrzebuję do tego celu kliknięcia Przycisk Usuń coś takiego:

enter image description here

+3

sprawiają, że duża obraz na tle div z układem względnym, a następnie umieść przycisk X w tym samym div z pozycją absolute top: 0px; prawe: 0 pikseli; – PaperThick

+0

Nie mogę, te obrazy ładują się dynamicznie, to jquery carousellist item –

+0

Właściwie litera ''×'' będzie dobrze.) – raina77ow

Odpowiedz

0

moim zdaniem można po prostu ustawić style="position:absolute;top:0px;right:0px;" dla RemoveButton.ico i style="position:relative;" dla div z img

0
<div style=" float: right;margin-left: 289px;position: absolute;">*</div> 
<img src="score.png" width="300" height="300" /> 

Spróbuj tego. To może pomóc.

0

Spróbuj czegoś podobnego

<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

1

mam zakodowane jedną up dla Ciebie http://jsfiddle.net/PPN7Q/

Trzeba owinąć obraz w div

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

i zastosuj następujące zasady CSS:

.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; 
} 
+0

Tutaj możemy uzyskać zdarzenie click dla głównego obrazu i usunąć? –

-1

Można spróbować to:

<div style="position:relative; width:'mainimagewidth'"> 
main image<img src="" /> 
<span style="position:absolute; top:0; right:0;">ximage<img src="" /></span> 
</div> 
31

Usual podejście z position: relative i 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; 
    ... 
} 

Rozszerzony demo (+ JS interakcja) http://jsfiddle.net/yHNEv/

0

Należy napisać plugin dla tego

(function ($, window, document, undefined) { 

'use strict'; 

var defaults = {}; 

var Delete = function (element) { 

    // You can access all lightgallery variables and functions like this. 
    this.core = $(element).data('lightGallery'); 

    this.$el = $(element); 
    this.core.s = $.extend({}, defaults, this.core.s) 

    this.init(); 

    return this; 
} 

Delete.prototype.init = function() { 
    var deleteIcon = '<span id="lg-clear" class="lg-icon deletePicture"><span class="glyphicon glyphicon-trash"></span></span>'; 
    this.core.$outer.find('.lg-toolbar').append(deleteIcon); 

    this.delete(); 

}; 


Delete.prototype.delete = function() { 
    var that = this; 
    var image_id = ''; 
    this.core.$outer.find('.deletePicture').on('click', function() { 
    // get vars from data-* attribute 
     image_id = that.core.$items.eq(that.core.index).data('id'); 
     table_name = that.core.$items.eq(that.core.index).data('table-name'); 

     /** 
     * Remove Touchpoint Retailer Image 
     */ 
     var formData = new FormData(); 
     formData.append('image_id', image_id); 
     $.ajax(......).success(function() 
     { 
      var thumbcount = that.core.$outer.find('.lg-thumb-item').length; 
      if(thumbcount >= 1) { 
       // remove slides 
      } 
      else { 
       that.core.destroy(); 
      } 
     }); 

    }); 
} 


/** 
* Destroy function must be defined. 
* lightgallery will automatically call your module destroy function 
* before destroying the gallery 
*/ 
Delete.prototype.destroy = function() { 

} 

// Attach your module with lightgallery 
$.fn.lightGallery.modules.delete = Delete; 


})(jQuery, window, document); 
Powiązane problemy