CSS:背景位置与重复? [英] CSS: background position with repeat?

查看:95
本文介绍了CSS:背景位置与重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个在y上重复的图片,但我想让它从div开始的位置开始20像素。

I currently have an image repeating on y, but I want it to start 20 px down from where the div starts....

我该怎么做?或<$ c $>之后,您应该使用

how do I do that?

推荐答案

c>:before 之前,因为没有必要在HTML中添加额外的标记。像这样:

Maybe you should use :after or :before for this, because there's no need to add extra markup in your HTML. Like this:

.container{
    height:400px;
    background:red;
    position:relative;
    width:400px;
}
.container:after{
    content:"";
    position:absolute;
    top:20px;
    left:0;
    right:0;
    bottom:0;
    background:url(http://lorempixel.com/400/200) repeat-y;
}

检查此http://jsfiddle.net/h6K9z/

它适用于IE8&以上。对于IE7或IE6,您可以为此提供额外的 DIV

It works in IE8 & above. For IE7 or IE6 you can give extra DIV for this.

这篇关于CSS:背景位置与重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆