动态设置图像位置 [英] Set image position dynamically

查看:94
本文介绍了动态设置图像位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Mozilla firefox.我在面板中动态创建了一个div,然后要在该div中显示图像.图像定位也是动态的.

我只想在div中动态设置图片?

请帮帮我.
谢谢.

[edit]已从评论中移出[/edit]

Hi all,

I am working with Mozilla firefox. I created a div in the panel dynamically and then I want to display a image in that div. Image positioning is also dynamic.

I just want to set an image in div dynamically ?

Please help me.
Thanks.

[edit]Moved from comment[/edit]

newImage.setAttribute(''width'',iw); 
newImage.setAttribute(''left'',ilf); 
newImage.setAttribute(''top'',itp); 
newImage.setAttribute(''height'',ih); 
newImage.style.display="block"; 


并用于显示图像....


and for display image....

if(strtext=="y") 
{ 
  newImage.src="jpgpreview\\" + filename+".JPG"; 
  //alert(newImage.src); 
} 
else if(filename !=null && filename !=" " && filename !="") 
{ 
  newImage.src= document.getElementByID(''hiddenVirtualPath_B'').value+filename+".JPG"; 
  //''http://rinki/webdir/temppdf/''+ filename+".JPG"; 
} 
if(strtext=="y") 
{ 
  newImage.src="jpgpreview\\" + filename+".JPG"; 
  // alert(newImage.src); 
} 
else if(filename !=null && filename !=" " && filename !="") 
{ 
  newImage.src= document.getElementById(''hiddenVirtualPath_B'').value+filename+".JPG"; 
  //''http://rinki/webdir/temppdf/''+ filename+".JPG"; 
}

推荐答案

document.all[''red''].style.margin-left="100pt";
document.all[''red''].style.margin-left="150pt";



JS片段将div标记和id red 移至相应位置.

您可以使用它来使用任何CSS样式.



The JS snippets moving the div tag with id red to a corrosponding position.

You can play with any CSS style with that.


实际上,您的问题使更多的问题感到困惑.

反正继续吧.

如何在其中动态添加图像div [ ^ ](实际上这有解决方案)

您也可以使用CSS进行定位

关于元素定位 [动态定位 [
Actually your question confusing more bit.

Anyway go ahead.

How to dynamically add image in div[^](Actually this has solution)

Also you can use CSS for positioning

About Element Positioning[^]

Dynamic Positioning[^]


这篇关于动态设置图像位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆