我有一个缩略图列表到一个链接到完整大小图像的hrefs。我想在全尺寸图像上添加一个关闭按钮。我正在考虑使用iframe。你会想到另一种做法吗?
非常感谢!
HTML
<div class="finishing-touches-contempovertical">
<a id="thumb" class="thumb1" href="images/image.jpg">
<img src="images/image-thumbnail.jpg"/>
</a>
</div>
CSS
a.thumb1 {
position: relative;
float: none;
margin: 20px 10px 10px 660px;
display: block;
width: 75px;
}
小提琴:
答案 0 :(得分:1)
使用popup和jquery
<style>
#popup{
display: none;
position: fixed;
z-index: 1000;
/* your styles */
}
</style>
<div class="finishing-touches-contempovertical">
<a id="thumb" class="thumb1" href="images/image.jpg">
<img src="images/image-thumbnail.jpg"/>
</a>
</div>
<div id="popup">
<img src="" />
<div class="close_popup">X</div>
</div>
<script>
$('a.thumb1').on('click',function(){ // when press link
var fullImg = $(this).attr('href') // get full size img url
$('#popup img').attr('src', fullImg) // image in popup now has source that you need
$('#popup').show() // popup appears
return false // do not redirect
})
$('.close_popup').on('click', function(){
$('#popup').hide() // close popup
})
</script>