【发布时间】:2012-01-11 18:32:54
【问题描述】:
我尝试重新创建我的类别小部件,因为我想将小图像合并到 CSS 精灵。代码在 Firefox 中看起来不错,但在 chrome 中,项目之间的空间更大。
我需要一些技巧来将唯一的 css 链接放在同一行中,并且我需要更多的行。这适用于 Firefox,但不适用于 google chrome。
HTML:
<ul class="css_sprite">
<div style="height: 55px; width: 260px; background-color: transparent;">
<span class="upper0">
<a href="#" class="rss_small"></a>
<a href="#" class="follow_icon"></a>
<a href="#" class="category">>> 1</a>
</span>
<span class="upper1">
<a href="#" class="rss_small"></a>
<a href="#" class="follow_icon"></a>
<a href="#" class="category">>> 2</a>
</span>
<span class="upper2">
<a href="#" class="rss_small"></a>
<a href="#" class="follow_icon"></a>
<a href="#" class="category">>> 3</a>
</span>
</div>
</ul>
CSS:
.css_sprite
{
list-style:none;
list-style-type:none;
}
.css_sprite a
{
display: block;
height: 15px;
outline: none;
}
.css_sprite a.rss_small
{
background-image:url('http://static.tumblr.com/puafveu/Uoilxj9e9/sombined_imges_for_css_sprites.png');
background-position:-1px 0px;
width: 49px;
height: 15px;
border: 0px;
}
.css_sprite a.follow_icon
{
background-image:url('http://static.tumblr.com/puafveu/Uoilxj9e9/sombined_imges_for_css_sprites.png');
background-position:-32px -15px;
width: 15px;
height: 15px;
position: relative;
left: 52px;
top: -15px;
}
.css_sprite span.upper0
{
position: relative;
top: -0px;
}
.css_sprite span.upper1
{
position: relative;
top: -27px;
}
.css_sprite span.upper2
{
position: relative;
top: -54px;
}
.css_sprite a.category
{
position: relative;
left: 73px;
top: -33px;
}
【问题讨论】:
-
您是否尝试过使用 CSS 重置来查看是否有帮助? stackoverflow.com/questions/116754/best-css-reset
-
使用起来太复杂了,我还有很多其他的组件。
-
@Pmillan 太复杂了?有什么比添加
reset.css更简单的呢?只需确保它是您的第一个 CSS 包含,以后的任何内容都会自动覆盖它 -
有些人使用重置。大多数没有。我公司没有。我们不需要。
标签: html css firefox google-chrome