:nth-of-type()类似于
:nth-child()它们必须全部来自同一父级。如果需要这些包装器
div,请改用
:nth-of-type()这些包装器:
div.post:nth-of-type(odd) .video-entry-summary { width:214px; height:210px; margin-left:0px; float:left; position:relative; overflow:hidden; border:1px solid black; background:#ccc; }
如果所有的兄弟姐妹
.post,用
:nth-child()代替,以防止混淆什么
:nth-of-type()的真正含义:
.post:nth-child(odd) .video-entry-summary { width:214px; height:210px; margin-left:0px; float:left; position:relative; overflow:hidden; border:1px solid black; background:#ccc; }.video-entry-summary { width: 214px; height: 210px; margin-left: 10px; float: left; position: relative; overflow: hidden; border: 1px solid black;}.post:nth-child(odd) .video-entry-summary { width: 214px; height: 210px; margin-left: 0px; float: left; position: relative; overflow: hidden; border: 1px solid black; background: #ccc;}<div id="post-501" > <div > video 1 </div></div><div id="post-240" > <div > video 2 </div></div><div id="post-232" > <div > video 3 </div></div><div id="post-223" > <div > video 4 </div></div>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)