拉伸背景图像设置为hr标签

时间:2012-05-23 07:31:21

标签: html css background-image

我有一个网页,其中我有hr个标签来分隔页面中的部分。

我使用css将图像作为hr标记的背景应用。

hr标记的宽度为100%,但图像不占用整个标记。

如何强制图片占据hr代码占用的整个区域?

是否有任何拉伸属性可用于端到端拉伸图像?

以下是代码:

hr
{

    background: url("images/new/edge-top.png") no-repeat scroll 0 0 transparent;
    color: transparent;
    height: 10px;
    margin: 0 auto;
    width: auto;
    clear: both;
    border: 0 none;
    display: block;
    padding: 0px;

}

在此处检查生成的图像:

enter image description here

1 个答案:

答案 0 :(得分:2)

CSS3有一些新的选择。尝试

background-size: x% x%;

在这里,您可以阅读 the Spec 了解新的后台模块。

但请注意,IE中的supported非常差! (有人感到惊讶吗?)