CSS CSS背景位置右上角添加边距?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9935030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS Background position top right add a margin?
提问by StevieB
So I have the following mark up :
所以我有以下标记:
background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat right top;
And its nearly perfect but i just want to add a bit of margin on top of the image, just wondering how I could add that to above.
它几乎完美,但我只想在图像顶部添加一点边距,只是想知道如何将其添加到上面。
回答by Bryan Downing
background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat right 10px;
background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat right 10px;
回答by paislee
Say you wanted 5 pixels of "margin":
假设您想要 5 个像素的“边距”:
/** replace 'top' with this vvv */
background: #7BC145 url("REDACTED") no-repeat right 5px;
回答by alf
Something like this?
像这样的东西?
background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat 100% 5px;
回答by ianaldo21
Just add margin-top:10px;
to the same line background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat right top; margin-top:10px;
只需添加margin-top:10px;
到同一行background: #7BC145 url(/images/ill_people_leadGen.png) no-repeat right top; margin-top:10px;