如何使具有负左值的CSS背景位置可见?
我有一个带有 list-style:none;
的
元素/code> 和
background-image:url(images/bullet.gif) no-repeat -20px 10px;
。
元素和带有 padding:20px;< 的
子弹不可见。 我现在使用的解决方法是背景位置和
元素 position:relative;padding-left:20px;margin-left:- 0 而不是 -20px 20 像素;
。有更好的方法吗?
编辑:我需要将项目符号放在
框之外。这就是使用负保证金的原因。谢谢。
I have a <ul>
element with list-style:none;
and <li>
with padding:20px;
and background-image:url(images/bullet.gif) no-repeat -20px 10px;
.
The bullet is not visible.
The workaround I'm using now is 0 instead -20px for the background-position and for the <li>
element position:relative;padding-left:20px;margin-left:-20px;
.
Is there a better way of doing this?
EDIT: I need the bullet to be outside of the <ul>
box. This being the reason for using negative margin.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个 jsfiddle 示例。 http://jsfiddle.net/jesseatkinson/z2qss/。
你的 CSS 应该是这样的。
Here is a jsfiddle example. http://jsfiddle.net/jesseatkinson/z2qss/.
Your CSS should look like this.
试试这个例子:
http://jsfiddle.net/sC8BR/2/
Try this example:
http://jsfiddle.net/sC8BR/2/