How to skip first child?
With the negation pseudo-class:
p:not(:first-child) { color: red; }
Browser support is very strong now, but alternatives include:
p { color: red; }
p:first-child { color: black; }
and:
* + p { color: red; }
CSS apply to all inside div but skip first child
Apply to all and remove it from the first one:
/* All the titles */.title-title:after { content: ""; display: block; width: 40%; margin-top: 5px; margin-left: auto; margin-right: auto; border: 1px red solid;}/* We remove from the first one*/#first .title-title:after { display:none;}
/* Part of my own external bootstrap rip off LUL */.py-ta-c { text-align: center;}
.py-mb-m { margin-bottom: 10%;}
<div id="first" class="py-ta-c py-mb-m"> <h2 class="title-title">First</h2> <h4 class="title-subtitle">Exclude me</h4></div>
<div id="second" class="py-ta-c py-mb-m"> <h2 class="title-title">Second</h2> <h4 class="title-subtitle">Include me</h4></div>
<div id="third" class="py-ta-c py-mb-m"> <h2 class="title-title">Third</h2> <h4 class="title-subtitle">Include me</h4></div>
<!-- AND SO ON -->
Skip first child of top level divs only
If you are just trying to apply the style to all the div
tags where you have assigned the "a" class except the first one, then you just need a minor modification to your css.
.want-to-skip-first-a .a:not(:first-child) {
background-color: red;
}
How to skip first N elements with CSS or jQuery?
You can use jQuery's slice method:
$('.my_div').slice(6)
A pure CSS approach is the nth-child selector:
.my_div:nth-child(n+6)
It seems to be supported by modern browsers: http://caniuse.com/#feat=css-sel3
Skip hidden element on :first-child selector
Sadly the :visible
pseudoclass is still distinct to jQuery. A workaround you can use though would be to handle the hiding by adding/removing a class.
Then it's a matter of overrides
li.hidden {
display: none;
}
li:not(.hidden) {
width: 100%;
height: 200px;
margin-bottom: 10px;
}
li:not(.hidden) ~ li {
width: auto;
height: auto;
margin-bottom: 0;
flex: 1;
}
CSS: is not a first child selector possible?
Yes, using :not
(:first-child)
parent child:not(:first-child) { /* style */ }
Example:
div span:not(:first-child) { color: red;}
<div> <span>A</span> <span>B</span> <span>C</span></div>
Can I use Nth-child to skip the first item then select 2 skip 2?
I'm not aware of any single-rule way to do it, but you can always just target two separate patterns with the same rule:
:nth-child(4n+2),
:nth-child(4n+3) {
background: black;
}
CSS selector for other than the first child and last child
Try:
#navigation ul li:not(:first-child):not(:last-child) {
...
}
Related Topics
Two Divs, One Fixed Width, the Other, the Rest
Do I Not Understand the Flex-Grow Property
Chrome:How to Turn Off User Agent Stylesheet Settings
How to Delay the Start of a CSS Animation
Transform-Origin for CSS Animation on Svg Working in Chrome, Not Ff
<!--[If Ie]> Conditional Comments Are Rendered HTML-Escaped in Facelets
How to Change Placeholder Color on Focus
Use Nth-Child Value as a SASS Variable
Webkit CSS to Control the Box Around the Color in an Input[Type=Color]
Align Button at the Bottom of Div Using CSS
How to Create Multi Columns from a Single Unordered List
CSS Transition Between Left -> Right and Top -> Bottom Positions
Differencebetween Background-Size: Cover; and Background-Size: 100%;
What Is the Most Practical Way to Check for "@Supports" Support Using Only CSS
How to Target a Specific Group of Siblings in a Flat Hierarchy