问题描述
我有一个具有10个像素边距的< div>
元素,如下面的代码所示。我的问题很简单:如何将背景图片放入边缘?我尝试过使用CSS3 background-clip
和 background-origin
子属性,但它们没有选项来扩展背景进入保证金。
I have a <div>
element that has a 10 pixel margin, as shown in the code below. My question is rather simple: how do I extend the background image into the margin? I tried using the CSS3 background-clip
and background-origin
sub-atributes, but they have no option for extending a background into the margin.
CSS:
CSS:
#pagesidebar
{
background-image:url('/Users/bagavatu/images/background.png');
margin:10px;
}
HTML:
HTML:
<div id="pagesidebar">Hello</div>
我知道我可以追加页面边栏
div转换为父div,并simpyl在那里应用background-image,但我更喜欢不需要新div的解决方案。
I know I could append the pagesidebar
div into a parent div, and simpyl apply the background-image there, but I would prefer a solution not requiring a new div.
推荐答案
开关保证金:10px
到 padding:10px
并且它应该有效。
Switch margin: 10px
to padding: 10px
and it should do the trick.
这篇关于将背景延伸到边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!