Selecting 2nd li of second occurrence of a class - css

I have
<ul class="biglist">
on many places of a page... in which i want to select only the second
<ul class="biglist">
and in that again select second li and add color to it...
i currently have it like follows
.biglist li:nth-child(2) {
color:#ff0000;
}
which i try to add...
.biglist:nth-child(2) li:nth-child(2)
it does not selects the second list's second item. Tried in internet search and could not able to get suitable solution. can someone help pls ?
Here is my complete code...
<div class="vc_col-sm-4 wpb_column column_container ">
<div class="wpb_wrapper">
<div class="dt-fancy-separator title-left accent-border-color" style="width: 100%;">
<div class="dt-fancy-title bg-on" style="color: #ffffff;">
<span class="separator-holder separator-left"></span>List of Places:
<span class="separator-holder separator-right"></span>
</div>
</div>
<div class="gap" style="line-height: 10px; height: 10px;"></div>
<section class="shortcode-teaser frame-fancy frame-on rotateInDownLeft animate-element">
<div class="shortcode-teaser-content text-big">
<ul class="biglist">
<li><p>New York</p></li>
<li><p>Ontario</p></li>
<li><p>London</p></li>
</ul>
</div>
</section>
<div class="gap" style="line-height: 30px; height: 30px;"></div>
</div>
</div>
<div class="vc_col-sm-4 wpb_column column_container ">
<div class="wpb_wrapper">
<div class="dt-fancy-separator title-left accent-border-color" style="width: 100%;">
<div class="dt-fancy-title bg-on" style="color: #ffffff;">
<span class="separator-holder separator-left"></span>List of Old Places:
<span class="separator-holder separator-right"></span>
</div>
</div>
<div class="gap" style="line-height: 10px; height: 10px;"></div>
<section class="shortcode-teaser frame-fancy frame-on rotateInDownLeft animate-element">
<div class="shortcode-teaser-content text-big">
<ul class="biglist">
<li><p>Mumbai</p></li>
<li><p>Tokyo</p></li>
<li><p>Bali</p></li>
</ul>
</div>
</section>
<div class="gap" style="line-height: 30px; height: 30px;"></div>
</div>
</div>
<div class="vc_col-sm-4 wpb_column column_container ">
<div class="wpb_wrapper">
<div class="dt-fancy-separator title-left accent-border-color" style="width: 100%;">
<div class="dt-fancy-title bg-on" style="color: #ffffff;">
<span class="separator-holder separator-left"></span>List of New Ones:
<span class="separator-holder separator-right"></span>
</div>
</div>
<div class="gap" style="line-height: 10px; height: 10px;"></div>
<section class="shortcode-teaser frame-fancy frame-on rotateInDownLeft animate-element">
<div class="shortcode-teaser-content text-big">
<ul class="biglist">
<li><p>Paris</p></li>
<li><p>Cairo</p></li>
<li><p>Delhi</p></li>
</ul>
</div>
</section>
<div class="gap" style="line-height: 30px; height: 30px;"></div>
</div>
</div>

My understanding is this is not possible in CSS using nth-child or nth-of-type.
The class check is done after the nth element check, so if there are other ul elements between those of class biglist, you have no guarantee of selecting the ul you are looking for.
You need a JavaScript based solution.
For example, using Jquery:
uls = $("ul");
var bigListCount = 0;
for(i = 0; i < uls.length; i++)
{
if($(uls[i]).hasClass("biglist")) bigListCount++;
if(bigListCount == 2){
$(uls[i]).css("color", "#ff0000");
}
}

You can try using :nth-of-type(N):
ul.biglist li:nth-of-type(2) { background-color: #ff0000; }

nth-of-type checks the occurrence of an item in its direct parent. In the case of your HTML, inside a div there is only one ul. So what you have to do is first select one of the top level elements (the column_container) and then set its ul's second li to red. Here you can see a working codepen example using your HTML.
https://codepen.io/tskjetne/pen/gWLKKr
For clarification, what I do is set the 2nd column_container's ul's 2nd li to color red.

Given the knowledge now that you have elements in between the ULs, css only will not work. Here's a jQuery solution:
if (($uls = $("ul.biglist")).length > 1){
$uls[1].find("li:nth-child(2)").css({ color: "#ff0000" })
}

Related

How to hide first pseudo css element

Is it possible to hide the first pseudo element?
<div id="builder-widgets_rule_0" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>
<div id="builder-widgets_rule_1" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>
<div id="builder-widgets_rule_2" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>
this html element has a pseudo styling like this:
.custom-condition::before {
content: '';
position: absolute;
width: 1px;
height: auto;
min-height: 25px;
border: 2px solid #f1f1f1;
top: -25px;
left: 50%;
margin-left: -2px;
}
It is not possible to do something like this?
.custom-condition:first-child::before {
content: '';
}
Also tried to added a span element to avoid the psuedo element like this:
<div id="builder-widgets_rule_0" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
<div class="smallLine"></div>
</div>
<div id="builder-widgets_rule_1" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
<div class="smallLine"></div>
</div>
<div id="builder-widgets_rule_2" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
<div class="smallLine"></div>
</div>
Just copied the psuedo styling to the .smallLine
If all the elements are inside the same wrapper you can do this. Instead of removing the pseudo-element from the first simply define it for all the other but not the first.
.custom-condition ~ .custom-condition::before {
content: '[Before]';
}
<div>
<div> OR </div>
<div class="custom-condition"> AND </div>
<div class="custom-condition"> AND </div>
<div> OR </div>
<div class="custom-condition"> AND </div>
</div>
UDPATE
You can consider the parent element with your current HTML structure
.rule-container ~ .rule-container .custom-condition::before {
content: '[Before]';
}
<div id="builder-widgets_rule_0" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>
<div id="builder-widgets_rule_1" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>
<div id="builder-widgets_rule_2" class="ruleTemplate rule-container">
<div class="custom-condition">AND</div>
</div>

Scroll for background is not working

I am implementing a chat module like linked-in or facebook. User List is one parent component (col-md-12) and after each user click, I am creating a new child component (col-md-3 each). Everything is working fine but the scroll option on (col-md-12) is not working. The position of parent and child component is fixed hence the background scroll is only working if I scroll outside col-md-12 class area.
<div class="row" >
<div class="content">
<div class="row">
<div class="col-md-12" id="ng-chat-view">
<div class="col-md-3 chat-farmer-list-ui">
<div id="ng-chat-people" [ngClass]="{'ng-chat-people-collapsed':isCollapsed}">
<a href="javascript:void(0);" class="ng-chat-title shadowed" matTooltip={{farmerListTooltip}} (click)="onChatTitleClicked($event)">
<span>
Farmer List
</span>
</a>
<input *ngIf="!isCollapsed" id="ng-chat-search_friend" type="search" placeholder="Search" [(ngModel)]="search" (ngModelChange)="getFarmerBySearchVal(search)"
/>
<ul id="ng-chat-users" *ngIf="!isCollapsed">
<li *ngFor="let user of farmers">
<div *ngIf="!user.imageUrl" class="icon-wrapper">
<i class="user-icon"></i>
</div>
<img *ngIf="user.imageUrl" alt="" class="avatar" height="30" width="30" src="{{user.imageUrl}}"/>
<strong title="{{user.user}}" (click)="openChatWindow(user, true)">{{user.name}}</strong>
</li>
</ul>
</div>
</div>
<div class="col-md-9 m-l">
<div *ngFor="let user of userInfo; let i = index">
<div>
<app-chatwindow [userInfo]="user" (onWindowCloseNotify)="onWindowCloseInChildComponent($event)"></app-chatwindow>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
#ng-chat-view{
position: fixed;
bottom: 0%;
margin-right: 10px;
font-family: Roboto,RobotoDraft,Helvetica,Arial,sans-serif;
font-size: 15px;
z-index:999;
cursor: pointer;
}
.row .m-l{
margin-left: -92px;
float: left;
}
#media (min-width: 992px){
.chat-farmer-list-ui {
float: right;
}
}

How to display child component from left to right

I am rendering child component in for loop from parent component. My parent component should be float to right at the bottom of screen then after each render of child component should be render to left to my parent component
Parent component :
<div class="row">
<div class="content">
<div class="row">
<div class="col-md-12" id="ng-chat-view">
<div class="col-md-3">
<div id="ng-chat-people" [ngClass]="{'ng-chat-people-collapsed':isCollapsed}">
<a href="javascript:void(0);" class="ng-chat-title shadowed" (click)="onChatTitleClicked($event)">
<span>
Farmer List
</span>
</a>
<input *ngIf="!isCollapsed" id="ng-chat-search_friend" type="search" placeholder="Search" [(ngModel)]="search" (ngModelChange)="getFarmerBySearchVal(search)"
/>
<ul id="ng-chat-users" *ngIf="!isCollapsed">
<li *ngFor="let user of farmers">
<div *ngIf="!user.imageUrl" class="icon-wrapper">
<i class="user-icon"></i>
</div>
<img *ngIf="user.imageUrl" alt="" class="avatar" height="30" width="30" src="{{user.imageUrl}}"/>
<strong title="{{user.user}}" (click)="openChatWindow(user, true)">{{user.name}}</strong>
</li>
</ul>
</div>
</div>
<div class="col-md-9 m-l">
<div *ngFor="let user of userInfo; let i = index">
<div>
<app-chatwindow [userInfo]="user" (onWindowCloseNotify)="onWindowCloseDeleteUserFromList($event)"></app-chatwindow>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I have attached screenshot of desired output :
Parent component should be:
Child component should be:
Current output:
Consider this example.
Parent should be floated to the right, as well as the childrens.
.chat {
float: right;
list-style: none;
}
.chat li {
width: 160px;
height: 200px;
background: red;
float: right;
margin-left: 10px;
}
<ul class="chat">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>

Remove border-right on :last-child psuedo-class

This is driving me nuts. I'm probably overlooking something super simple since I normally don't have issues with something like a psuedo-class.
I'm trying to remove the right border on a div element for the last-child. I can have it work with a class on the last element, but I don't need to do it that way (since the content will be in an ee loop).
Here is the code. Everything is wrapped in a section with an id of #small-featured. All the content that is nested in bootstrap columns is wrapped in a #featured-wrapper.
<section id="small-featured">
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="featured-wrapper">
<img src="assets/img/36-6022.png" alt="">
<p>The Product Title</p>
</div>
</div>
<div class="col-md-3">
<div class="featured-wrapper">
<img src="assets/img/36-5100.jpg" alt="">
<p>The Product Title</p>
</div>
</div>
<div class="col-md-3">
<div class="featured-wrapper">
<img src="assets/img/46-455.jpg" alt="">
<p>The Product Title</p>
</div>
</div>
<div class="col-md-3">
<div class="featured-wrapper">
<img src="assets/img/unisaw.jpg" alt="">
<p>The Product Title</p>
</div>
</div>
</div>
</div>
</section>
Here is CSS
#small-featured {
text-align: center;
}
#small-featured img {
width: 250px;
padding: 0 15px;
}
.featured-wrapper {
border-right: 1px solid #eee;
}
#small-featured .featured-wrapper:last-child {
border-right: none;
}
All the borders disappear when I add my last bit of CSS. I've tried targeting just .featured-wrapper:last-child as well.
Any ideas?
#small-featured .col-md-3:last-child .featured-wrapper {
border-right: none;
}
(All .featured-wrapper are :last-child.) ¯\_(ツ)_/¯

bootstrap link area smaller on focus and active?

I have a thumbnail gallery and each of the <a> elements have an outline around them, when I click on one of the links, the outline is noticeably shorter (only by a pixel or two but enough to be annoying) than the surrounding elements
link to codepen - http://codepen.io/Davez01d/pen/NxMzYy?editors=1100
here's the html -
<div class="row vert-space-30"><!--row-->
<div id="padding-helper"><!--padding-helper-->
<div class="col-sm-3 col-xs-6 port-tile text-center">
<a class="thumbnail" href="http://codepen.io/Davez01d/full/obyBbz/" target="_blank">
<img src="http://i1155.photobucket.com/albums/p558/Davez01d/Portfolio%20site-Codepen/f043ed05-0df8-42b9-a7b3-57ad6cab5f3b_zpsq2074gko.png" alt="Pomodoro thumbnail"/>
<div class="caption">
<h4>Pomodoro Timer</h4>
<p class="tech-used">JavaScript, jQuery, HTML, Css</p>
</div>
</a>
</div>
<div class="col-sm-3 col-xs-6 port-tile text-center">
<a class="thumbnail" href="http://codepen.io/Davez01d/full/JGvdxX/" target="_blank">
<img src="http://i1155.photobucket.com/albums/p558/Davez01d/Portfolio%20site-Codepen/726c239e-157c-4e4d-8931-77f3a4c9de9c_zpslofzlecy.png" alt="Calculator thumbnail"/>
<div class="caption">
<h4>JavaScript Calculator</h4>
<p class="tech-used">JavaScript, jQuery, HTML, Css</p>
</div>
</a>
</div>
<div class="col-sm-3 col-xs-6 port-tile text-center">
<a class="thumbnail" href="http://codepen.io/Davez01d/full/gPegpd/" target="_blank">
<img src="http://i1155.photobucket.com/albums/p558/Davez01d/Portfolio%20site-Codepen/e9b19619-ed3c-4149-ab15-0a039c59f5a7_zps7vmaslo8.png" alt="Quote generator thumbnail"/>
<div class="caption">
<h4>Random Quote Generator</h4>
<p class="tech-used">jQuery, twitter API</p>
</div>
</a>
</div>
<div class="col-sm-3 col-xs-6 port-tile text-center">
<a class="thumbnail" href="http://codepen.io/Davez01d/full/KVQzwr/" target="_blank">
<img src="http://i1155.photobucket.com/albums/p558/Davez01d/Portfolio%20site-Codepen/cc4d40ed-a085-43d6-9dde-90c59161b023_zps0ppintnt.png" alt="Web sketchpad thumbnail"/>
<div class="caption">
<h4>Web Sketchpad</h4>
<p class="tech-used">jQuery, HTML, CSS</p>
</div>
</a>
</div>
</div><!--padding-helper-->
</div><!--row-->
and the css-
.port-tile a {
z-index: 0;
position: relative;
border-radius: 0;
border: none;
padding: 0;
outline: 3px solid #d63c20;
transition: all .12s ease;
}
.port-tile a:hover {
z-index: 10;
outline: 3px solid #d63c20;
transform: scale(1.12, 1.12);
}
.port-tile a:active, a:focus {
outline: 3px solid #d63c20;
}
Also side-note, I'm finding it hard to find a list of all the bootstrap effects on links, buttons, etc, is there a good resource for this? it would help me out a lot.
It's the a:focus { outline-offset: -2px; } that I believe you're referring to, which causes this:
You could override that with your own style, just set
a:focus {
outline-offset: 0;
}
if you don't have a need for this rule at all. Or, target the specific elements where you wish to remove it.

Resources