我想使特定帖子周围的容器与相邻的容器颜色不同。基本上,容器只需要在两种不同颜色之间循环。
左边是当前的样子,右边是我想要的样子。谢谢!
CSS
#content {
float:left;
width:800px;
padding:25px;
top:-50px; left:45px;
background:transparent;
{block:PermalinkPage}
width:300px;
{/block:PermalinkPage}
}
.entry {
width:150px;
margin:50px;
overflow:hidden;
background:#336136;
margin-left:-12px;
margin-bottom: -10px;
padding:12px;
{block:PermalinkPage}
width:250px;
margin-left:40px;
{/block:PermalinkPage}
}
.entry:nth-child(odd) {
background: #000;
}
HTML
<div id="content">
{block:Posts}
<div class="entry">
{miscellaneous_blocks_here}
</div>
{/block:Posts}
</div>
最佳答案
为什么不使用 CSS3 选择器并放弃 javascript 舞蹈?
.entry:nth-child(odd) {
background: #000;
}
.entry:nth-child(even) {
background: #ff003d
}
关于javascript - Tumblr 帖子在两种不同颜色之间循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24658949/