Using nth child to select one particular sibling - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:nth-child

Description

Using nth child to select one particular sibling

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi</title> 
  <style>
.flexcontainer {<!--from  w  w  w  .  java2  s .  co  m-->
   display:flex;
}

.photocontainer,
.spr,
.wint,
.aut {
   width:301px;
   height:201px;
   margin:6px;
   position:relative;
}

.overlay {
   transition:.6s;
   position:absolute;
   top:0;
   left:0;
   right:0;
   bottom:0;
   width:301px;
   height:201px;
   background:black;
   opacity:0;
   margin:6px;
}

.photocontainer p {
   position:absolute;
   font-size:3em;
   color:Chartreuse;
   font-family:verdana;
   text-align:center;
   top:21px;
   left:0;
   right:0;
   bottom:0;
   margin:6px;
   z-index:2;
   transition:.6s;
   opacity:0;
}

.photocontainer:hover .overlay {
   transition-delay:.3s;
   transition-duration:2s;
   opacity:0.7;
}

.photocontainer:hover p {
   transition-delay:.3s;
   transition-duration:2s;
   opacity:2;
}

.photocontainer:hover:last-child .overlay {
   opacity:0.4;
}
</style> 
 </head> 
 <body translate="no"> 
  <div class="flexcontainer"> 
   <div class="photocontainer"> 
    <img class="spr" src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
    <div class="overlay"></div> 
    <p>Lorem ipsum do</p> 
   </div> 
   <div class="photocontainer"> 
    <img class="wint" src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
    <div class="overlay"></div> 
    <p>Lorem ipsum do</p> 
   </div> 
   <div class="photocontainer"> 
    <img class="aut" src="https://www.java2s.com/style/demo/Firefox.png"> 
    <div class="overlay"></div> 
    <p>Lorem ipsum do</p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials