在这里找到了一个指南,可以通过单击放大图片,但它不太有效。当我点击放大图像时,小的留在前面。
我把它放在我的html中:
<div class="bild1"><script type="text/javascript" src="funktions.js"></script>
<img src="bilder/3D.png" alt="Almanacka-projekt" style="cursor:pointer" onclick="showImage('bilder/3D_stor.png');">
<div id="largeImgPanel" onclick="hideMe(this);">
<img id="largeImg" style="height: 100%; margin: 0; padding: 0;">
</div>
</div>
<div class="bild2">
<img src="bilder/TopGame.png" alt="Almanacka-projekt" style="cursor:pointer" onclick="showImage('bilder/TopGame_stor.png');">
<div id="largeImgPanel" onclick="hideMe(this);">
<img id="largeImg" style="height: 100%; margin: 0; padding: 0;">
</div>
</div>
<div class="bild3">
<img src="bilder/almanacka.png" alt="Almanacka-projekt" style="cursor:pointer" onclick="showImage('bilder/Almanacka_stor.png');">
<div id="largeImgPanel" onclick="hideMe(this);">
<img id="largeImg" style="height: 100%; margin: 0; padding: 0;">
</div>
</div>
CSS:
#largeImgPanel {
text-align: center;
visibility: hidden;
position: fixed;
z-index: 100;
top: 0; left: 0;
width:100%;
height:100%;
background-color: rgba(100,100,100, 0.5);}
javascript:
function showImage(imgName) {
document.getElementById('largeImg').src = imgName;
showLargeImagePanel();
unselectAll();
}
function showLargeImagePanel() {
document.getElementById('largeImgPanel').style.visibility = 'visible';
}
function unselectAll() {
if(document.selection) document.selection.empty();
if(window.getSelection) window.getSelection().removeAllRanges();
}
function hideMe(obj) {
obj.style.visibility = 'hidden';}
当我有多张照片时,我应该做不同的事情吗?