9. April 2015
von Blackbam

Recently I discovered some short solution for ignoring a single hidden element with the nth-child selector. If you struggle with the same problem the following might be useful:

This is the HTML:

a
b
c
d
e

The following CSS adds a margin right to every second visible element no matter which element has the cpw class.

.cpw {
    display:none;
}

.video_prewrap {
    margin-right:20px;
}

.video_prewrap:nth-child(2n) {
    margin-right:0;
}

.cpw ~ .video_prewrap:nth-child(2n) {
    margin-right:20px;
}

.cpw ~ .video_prewrap:nth-child(2n-1) {
    margin-right:0;
}

Share

Dieser Eintrag wurde am 9. April 2015 um 0:00 in der Kategorie CSS veröffentlicht. You can book the comments for this article RSS 2.0. Feedback, discussion, commendation and critics are welcome: Write a comment or trackback.


Tags: , ,

No comments yet

Kommentare abonnieren (RSS) or URL Trackback

Leave a comment:

Warning: Undefined variable $user_ID in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/comments.php on line 92