我正在尝试创建一个非常基本的windows桌面小工具来显示我的堆栈溢出天赋。
我对html或web开发没有太多经验。我试着按照说明操作,但是当我安装这个小工具时它很小:
是的,就是那个小小的白色正方形。
我试过设置背景图像,但似乎也不起作用(我其实不需要背景图像,我只是想让它发挥作用)。如果我单独运行HTML源文件,则它将正确显示在浏览器中:
以下是来自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>

我试过在这里取消对图像链接的注释,但它没有任何改变。
关于如何正确设置大小的任何想法都将非常感谢。

最佳答案

我找到了解决办法。我找到了一个可以插入到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>

10-07 19:08
查看更多