私は自分自身が外部のJSソースを使用せずにライセンスを取得することもできます。絶対位置を設定し、幅と高さを100%に設定し、divのocupacyで遊んでください。私は画像を中心にするために余分なテーブルを作成する必要があった、divで動作しませんでした。他のすべての要素の上にdivとtableを置くためにz-indexを忘れないでください。歓声...
function enlargeimage(x)
{
var a = document.getElementById('_enlargeimg');
a.style.height = x + '%';
a.style.width = x + '%';
x++;
if (x < 90)
{ setTimeout("enlargeimage(\"" + x + "\")", 5);}
}
function reduceimage(x)
{
var a = document.getElementById('_enlargeimg');
a.style.height = x + '%';
a.style.width = x + '%';
x--;
if (x > 0)
{ setTimeout("reduceimage(\"" + x + "\")", 5);}
else
{
b = document.getElementById('_enlargediv');
c = document.getElementById('_enlargetable');
b.parentNode.removeChild(b);
c.parentNode.removeChild(c);
document.body.style.overflow = 'auto';
}
}
function createelements(imgfile)
{
var divbackground = document.createElement('div');
divbackground.setAttribute('id', '_enlargediv');
divbackground.style.width = '100%';
divbackground.style.height = '100%';
divbackground.style.position= 'absolute';
divbackground.style.background= '#000';
divbackground.style.left= '0';
divbackground.style.top= '0';
divbackground.style.opacity= 0.7;
divbackground.style.zIndex= '1';
document.body.appendChild(divbackground);
var tblbackground = document.createElement('table');
tblbackground.setAttribute('id', '_enlargetable')
tblbackground.style.width = '100%';
tblbackground.style.height = '100%';
tblbackground.style.position= 'absolute';
tblbackground.style.left= '0';
tblbackground.style.top= '0';
tblbackground.style.zIndex= '2';
tblbackground.style.textAlign = 'center';
tblbackground.style.verticalAlign = 'middle';
tblbackground.setAttribute('onClick', 'reduceimage(90)');
var tr = tblbackground.insertRow();
var td = tr.insertCell();
var nimg = document.createElement('img');
nimg.setAttribute('src', imgfile);
nimg.setAttribute('id', '_enlargeimg');
nimg.style.width='0px';
nimg.style.height='0px'
nimg.style.borderRadius = '5px';
td.appendChild(nimg);
document.body.appendChild(tblbackground);
document.body.style.overflow = 'hidden';
enlargeimage(0);
}
ありがとうございます。jQueryの.dialogまたは同様のウィジェットを使用して画像を拡大できますか? – Mosaic
答えはほとんど常に「はい」ですが、私はあなたの質問の文脈がありません。なぜまだコードを表示していないのですか? –