如何设置您创建的桌面小工具的大小

时间:2013-09-15 08:38:25

标签: html windows windows-7 windows-desktop-gadgets

我正在尝试创建一个非常基本的Windows桌面小工具来显示我的Stack Overflow Flair。

我对html或web开发没有多少经验。我试图按照here的说明进行操作,但是当我安装小工具时,它很小:

enter image description here

是的,就是那个小小的白色方块。

我尝试过设置背景图片,但它似乎也没有用(我实际上并不需要背景图片,我只是想让它工作)。如果我独立运行html源文件,那么它会在浏览器中正确显示:

enter image description here

以下是html源文件(名为MySOFlair.html)的代码:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>

  <body>
    <div id="gadgetContent">
      <a href="http://stackoverflow.com/users/2012446/chrisprosser">
        <img src="http://stackoverflow.com/users/flair/2012446.png" width="208" height="58" 
             alt="profile for ChrisProsser at Stack Overflow, Q&amp;A for professional and enthusiast programmers" 
             title="profile for ChrisProsser at Stack Overflow, Q&amp;A for professional and enthusiast programmers"/>
      </a>
    </div>
  </body>
</html>

以下是清单文件(Gadget.xml)中的代码:

<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>MySOFlair</name>
  <version>1.0.0.0</version>
  <author name="Chris Prosser" />
  <description>Mt Stack Overflow Flair Gadget</description>
  <!--<icons>
    <icon src="http://stackoverflow.com/users/flair/2012446.png" 
          width="208" 
          height="58" />
  </icons>-->
  <hosts>
    <host name="sidebar">
      <base type="HTML" apiVersion="1.0.0" src="MySOFlair.html" />
      <permissions>Full</permissions>
      <platform minPlatformVersion="1.0" />
      <!--<defaultImage src="http://stackoverflow.com/users/flair/2012446.png" 
                    width="208" 
                    height="58"/>-->
    </host>
  </hosts>
</gadget>

我已尝试在此处取消注释图片链接,但它不会改变任何内容。

非常感谢任何有关如何正确设置尺寸的想法。

1 个答案:

答案 0 :(得分:2)

我找到了解决这个问题的方法。我发现了一个可以插入HTML标题部分的样式元素。这是新的HTML文件:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    body
    {
       margin:  0;
       width: 212;
       height: 62;
    }
    #gadgetContent
    {
       margin:  0px;
       width: 208px;
       height: 58px;
    }
    </style>
  </head>

  <body>
    <div id="gadgetContent">
      <a href="http://stackoverflow.com/users/2012446/chrisprosser">
        <img src="http://stackoverflow.com/users/flair/2012446.png" width="208" height="58" 
             alt="profile for ChrisProsser at Stack Overflow, Q&amp;A for professional and enthusiast programmers" 
             title="profile for ChrisProsser at Stack Overflow, Q&amp;A for professional and enthusiast programmers"/>
      </a>
    </div>
  </body>
</html>
相关问题