Jessica Jessica - 2 months ago 6
CSS Question

Select all but first class element not working

I'm trying to select all, but the first class element. I'm doing

.title:not(:first-child)
, but it's not working.

What am I doing wrong, and how can I fix it? Here's the code:

JSFiddle





.title:not(:first-child) {
padding-top: 100px;
}

<div class="outer-wrapper">
<div class="inner-wrapper">
<h4 class="title">First Tittle</h4>
</div>
<div class="inner-wrapper">
<h4 class="title">Second Tittle</h4>
</div>
</div>




Answer

Your title is always the first child. Try the following:

.inner-wrapper:not(:first-child) .title{
  padding-top: 100px;
}

Or

.inner-wrapper:nth-child(n+1) .title{
  padding-top: 100px;
}
Comments