css :nth-child 随机跳过列表项
在尝试自己解决问题几天后,我在这里发帖。我有一个无序列表,其列表项包含几个内容,包括我用来显示来自精灵的图像的 div。
这是 html :
<ul class="upperList clearfix">
<li>
<h3>Kit détecteur extérieur images</h3>
<p></p>
<div class="extrasLiBg"></div>
<p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.</p>
</li>
<li>
<h3>Bouton anti hold-up avec capture d'images</h3>
<div class="extrasLiBg"></div>
</li>
<li>
<h3>Pendentif Verisure [me]</h3>
<div class="extrasLiBg"></div>
</li>
</ul>
这是 css :
.extrasLiBg {
width:100px;
height:100px;
position:absolute;
bottom:0;
right:0;
overflow:hidden;
background:url('images/extras-sprite.jpg') no-repeat;
}
.extras .upperList li:nth-child(2) .extrasLiBg {background-position:-100px 0;}
.extras .upperlist li:nth-child(3) .extrasLiBg {background-position:-200px 0;}
我的问题是,最后一个列表项中的 div 不知何故拒绝移动背景图像,因此显示精灵中的第一个左上角图像...... 这让我抓狂,页面上还有其他列表,它们的 div 可以毫无问题地显示精灵的正确部分...
我正在使用 Chrome 10 顺便说一句,但问题仍然存在于 Firefox、Safari 和 Opera(最新的发布)。
感谢您的任何帮助。
I'm posting here after trying to resolve my problem on my own for a couple of days. I have an unordered list whose list items contain several things including a div I use to display an image coming from a sprite.
Here is the html :
<ul class="upperList clearfix">
<li>
<h3>Kit détecteur extérieur images</h3>
<p></p>
<div class="extrasLiBg"></div>
<p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.</p>
</li>
<li>
<h3>Bouton anti hold-up avec capture d'images</h3>
<div class="extrasLiBg"></div>
</li>
<li>
<h3>Pendentif Verisure [me]</h3>
<div class="extrasLiBg"></div>
</li>
</ul>
And here is the css :
.extrasLiBg {
width:100px;
height:100px;
position:absolute;
bottom:0;
right:0;
overflow:hidden;
background:url('images/extras-sprite.jpg') no-repeat;
}
.extras .upperList li:nth-child(2) .extrasLiBg {background-position:-100px 0;}
.extras .upperlist li:nth-child(3) .extrasLiBg {background-position:-200px 0;}
My problem is, the div within the last list item somehow refuses to shift the background image, and thus displays the first, top left image in the sprite...
It's driving me nuts, there are other lists on the page too and their div have no problem displaying the right part of the sprite...
I'm using Chrome 10 btw, but the problem remains in Firefox, Safari and Opera (most recent releases).
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第三个子级的选择器中,将
.upperlist
更改为.upperList
。In the selector for the thrird child, change
.upperlist
to.upperList
.