2011-01-14 69 views
1

我有HTML这样的:CSS:裕IMG

<div id="userBar"> 
<a href="notifications.php" class="iconGlobe"></A> 
<a href="cp.php" class="iconCP"></a> 
<a href="cap.php" class="iconCAP"></a> 
    </div> 

.iconGlobe是看起来像这样一个图标,同时与redst:

.iconGlobe{ 
background: url(../images/icons/globe_16x16.png) no-repeat; 
width: 16px; 
height: 16px; 
border: none; 
display:inline-block; 
position:relative; 
text-decoration:none; 
} 

我试着去之间给保证金锚链接,如下所示:

#userbar a{ 
margin-right: 8px; 
} 

但我不适用保证金。我试图单独这样做.iconGlobe有保证金的权利,而且工作得很好。我不希望单独应用它们。

+0

我不认为你需要`position:relative;`on .iconGlobe。你在测试哪个浏览器?你有没有现场的例子? – Kyle 2011-01-14 09:56:40

回答

2

其案件的问题?在你的HTML你有

<div id="userBar"> - 注意国会大厦B和在CSS你有

#userbar a{
- 小写的B ....没有

的,你需要有块元素的利润率 -

#userBar a{ display:block} 
+0

内嵌块元素可以有边距 – kapa 2011-01-14 11:48:47

1

试试这个:

#userbar a{ 
    display: block; 
    float: left; 
    margin-right: 8px; 
} 
+0

如果父div“中断”,试试这个:+ – 2011-01-14 09:56:20

3

你不能给内联元素留出余地。更改您的代码:

#userbar a{ 
display: inline-block; 
margin-right: 8px; 
} 

但要注意,旧版本的IE可能会忽略这个...

1

你的代码是正确的。这个问题与#useBar和id ='usebar'的情况不匹配。当案例得到纠正后,它可以正常工作。看到这里 - http://jsfiddle.net/pGpwb/