如何用RESIZABLE图像替换#site-title?

时间:2012-02-12 22:13:37

标签: css3 wordpress-theming image-resizing

我可以替换#site-title文字with a fixed-size image,没问题。

但现在我想根据浏览器的大小自动调整大小,就像WordPresse在Twenty Eleven中的标题一样。

FireBug告诉我,负责的是:

#branding img {
    height: auto;
    margin-bottom: -7px;
    width: 100%;
}

但是当我尝试将其复制到网站标题时:

 #site-title {
    text-indent: -9999px;
    width: 100%;  /* 980px;  width of the image file. */
    height: auto; /* 128px;  height of the image file. */

    margin: 0px 0 0 0;
    padding: 0em 0 0;
    background: url(images/header.png) white no-repeat;
    font-size: 1px;
    line-height: 1px;
    text-decoration: none;
}

这不起作用:网站标题图像保持原始尺寸相同。

我还需要做些什么来创建新WordPress的“可调整大小的魔法”功能吗?

1 个答案:

答案 0 :(得分:2)

要调整图像大小,必须调整父元素的大小。如果采用二十一个主题,#page元素虽然具有最大宽度,但没有width。然后,width:100%图片将根据浏览器宽度调整大小。