html - How to make outer div doesn't react when inner div is :active in css -


i have 2 div's inside each other. outer 1 bigger when click on outer changes far used .outer:active in css. when click on inner changes (i used .outer .inner:active), outer div changes also.

here's jsfiddle: https://jsfiddle.net/hetjwnxa/2/

html:

<div class="testimonials-content">  <div class="testimonials-square">   <a href="">       <div class="translation-button">     <p>translate</p>   </div> </a> <a href="">   <div class="testimonials-square-text">     <p>title</p>   </div> </a> </div> <div class="testimonials-square">   <a href="">       <div class="translation-button">     <p>translate</p>   </div> </a> <a href="">   <div class="testimonials-square-text">     <p>title</p>   </div> </a> </div> <div class="testimonials-square">   <a href="">       <div class="translation-button">     <p>translate</p>   </div> </a> <a href="">   <div class="testimonials-square-text">     <p>title</p>   </div> </a> </div> </div> 

and here css:

.testimonials-content { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; width: 750px; background-color: #ffffff; }  .testimonials-square { width: 214px; height: 214px; border-radius: 10px; border: 5px solid #282165; color: #282165; font-size: 22px; text-align: center; float: left; margin-right: 26px; margin-bottom: 27px; background-color: #ffffff; text-align: center; color: #282165; font-weight: bold; }  .translation-button { width: auto; height: auto; border-radius: 2px; border: 2px solid #282165; color: #282165; font-size: 22px; text-align: center; float: left; margin: 5px; background-color: #ffffff; text-align: center; color: #282165; font-weight: bold; }  .testimonials-square .translation-button p { color: #ffffff; background-color: #282165; }  .testimonials-square-text { margin-top: 80px; margin-left: 20px; margin-right: 20px; text-align: center; }  .testimonials-square p { color: #282165; }  .testimonials-square:active { background-color: #282165; color: #ffffff; }  .testimonials-square .translation-button:active p { color: #282165; background-color: #ffffff; }  .testimonials-square:active p { background-color: #282165; color: #ffffff; }  .testimonials-square:nth-child(2n+1) { background-color: #282165; color: #ffffff; }  .testimonials-square:nth-child(2n+1) .translation-button { border: 2px solid #ffffff; }  .testimonials-square:nth-child(2n+1) .translation-button p { background-color: #ffffff; color: #282165; }  .testimonials-square:nth-child(2n+1) .translation-button:active p { background-color: #282165; color: #ffffff; }  .testimonials-square:nth-child(2n+1) p { background-color: #282165; color: #ffffff; }  .testimonials-square:nth-child(2n+1):active { background-color: #ffffff; color: #282165; }  .testimonials-square:nth-child(2n+1):active p { background-color: #ffffff; color: #282165; }  p {   margin: 0px; }  {    text-decoration: none; }  

how can make outer div not change after clicking on inner div?

any appreciated. thanks!

when element :active, it's ancestor elements :active too, obvious reasons.

in case, if have access html, add element (e.g. .testimonials-bg) inside .testimonials-square sibling .translation-button , style stretches fit .testimonials-square , add :active style it.

html

<div class="testimonials-content">   <div class="testimonials-bg"></div>   <div class="testimonials-square">     <a href="">       <div class="translation-button">         <p>translate</p>       </div>     </a>     <a href="">       <div class="testimonials-square-text">         <p>title</p>       </div>     </a> </div> 

css

.testimonials-bg {   position:absolute;   top:0;   left:0;   right:0;   bottom:0; } .testimonials-bg:active {   background-color: #282165; } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -