1

我并不是说使用 调整大小<img src="URL" width="Xy%" height="za%">,尽管它的外观与我的目标相同。我想要类似僵尸狗代码的东西,但图像大小任意。请阅读我的代码中的注释。

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="" />

<Content type="html">
<![CDATA[

// This won't change the size of the image but the size of div.

<style type="text/css">
#zombiecontainer{
height:100%;
width:100%;
}
</style>

// I want to specify the size of the image with Div -block relative to the size
// of iGoogle gadget.

<div id="zombiecontainer"
style="text-align:center;" width="100%" height="100%">
</div>


<script type="text/javascript">
var images = new Array();
images[0] = _IG_GetImage("https://pictures/friends.jpg");

// How can I do it with the div? I don't want to create a static picture
// and put the code to the div block. I want to be able to change it,
// hopefully, with below commands. No more messy HTML.

_gel("zombiecontainer").innerHTML = "";
_gel("zombiecontainer").appendChild(images[0]);

</script>
</div>
]]>
</Content>
</Module>
4

2 回答 2

1

不太确定我是否理解您的问题,但这会起作用吗?

<style type="text/css">
#zombiecontainer img{
height:50%;
width:50%;
}
</style>

这会将僵尸容器 div 中任何图像的高度和宽度设置为您定义的任何值(在本例中为 div 的 50%)。

于 2010-12-23T04:26:17.833 回答
0

我将解决一个 Piontek Media 没有解决的小问题。如果您希望图像像示例中一样居中,则需要以下内容,因为它不能位于图像块内。

<style type="text/css">
#zombiecontainer img{
height:50%;
width:50%;
}

#zombiecontainer {
text-align:center;
}
</style>

如果您可以更简洁地做到这一点,请告诉我。

于 2010-12-25T01:15:35.787 回答