【发布时间】:2013-02-06 21:52:27
【问题描述】:
我正在尝试在我的网站中对我的 div 进行斑马条纹,听起来很简单,但是我发现当我在我的 div 的行之间添加一个标题时,它似乎计算了奇数/偶数样式中的标题
HTML
<div class="container">
<h3>Title</h3>
<div class="row">Content</div>
<div class="row">Content</div>
<h3>Title</h3>
<div class="row">Content</div>
<div class="row">Content</div>
<div class="row">Content</div>
<h3>Title</h3>
<div class="row">Content</div>
<div class="row">Content</div>
<div class="row">Content</div>
<div class="row">Content</div>
</div>
CSS
.container {
width:600px;
margin:0 auto;
}
.row {
line-height:24pt;
border: solid 1px black;
}
.row:nth-child(odd) {
background: #e0e0e0;
}
h3 {
line-height:36pt;
font-weight:bold;
color:blue;
}
我原以为已经在小提琴中的代码基本上会忽略标题并继续进行条带化,但似乎它认为标题是一个孩子
【问题讨论】:
标签: css html zebra-striping