jQuery็ฆ็”จๆ‚ฌๅœๆ•ˆๆžœonClick

ๆ—ถ้—ด๏ผš2015-08-22 15:23:23

ๆ ‡็ญพ๏ผš javascript jquery html css3 hover

http://codepen.io/jzhang172/pen/YXoWZa

$(function(){



$('.tint.first').on('click', function() {
	$(this).toggleClass('clicked');
   
    
});


$('.tint.one').on('click', function() {
	$(this).toggleClass('clicked');
   
    
});


$('.tint.two').on('click', function() {
	$(this).toggleClass('clicked');
   
    
});
});
/* Shared
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.button {
  border-radius: 100px;
}

/* Sections
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.section {
  padding: 8rem 0 7rem;
  text-align: center;
}
.section-heading,
.section-description {
  margin-bottom: 1.2rem;
}

/* Hero
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.phones {
  position: relative;
}
.phone {
  position: relative;
  max-width: 80%;
  margin: 3rem auto -12rem;
}
.phone + .phone {
  display: none;
}

/* Values
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.values {
  background-image: url('../img/values-bg.jpg');
  background-size: cover;
  color: #fff;
  padding-bottom: 5rem;
}

.value-multiplier {
  margin-bottom: .5rem;
  color: #11DFC7;
}
.value-heading {
  margin-bottom: .3rem;
}
.value-description {
  opacity: .8;
  font-weight: 300;
}

/* Help
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.get-help {
  border-bottom: 1px solid #ddd;
}

/* Categories
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.categories {
  background-image: url('../img/values-bg.jpg');
  background-size: cover;
  color: #fff;
}
.categories .section-description { 
  margin-bottom: 4rem;
}

/* Bigger than 550 */
@media (min-width: 550px) {
  .section {
    padding: 12rem 0 11rem;
  }
  .hero {
    padding-bottom: 12rem;
    text-align: left;
    height: 165px;
  }
  .phone {
    position: absolute;
    top: -7rem;
    right: 3rem;
    max-height: 362px;
    z-index: 3;
  }
  .phone + .phone {
    top: -6rem;
    display: block;
    max-width: 73.8%;
    right: 0;
    z-index: 2;
    max-height: 338px;
  }
  .hero-heading {
    font-size: 3.0rem;
    position:relative;
    z-index:100;
    color:black;
    font-weight:600;

  }
}

/* Bigger than 750 */
@media (min-width: 750px) {
  .hero {
    height: 190px;
  }
  .hero-heading {
    font-size: 3.2rem; z-index:100;color:black;
  }
  .section {
    padding: 14rem 0 15rem;
  }
  .hero {
    padding: 16rem 0 14rem;

  }
  .section-description {
    max-width: 60%;
    margin-left: auto;
    margin-right: auto;
  }
  .phone {
    top: -14rem;
    right: 5rem;
    max-height: 510px;
  }
  .phone + .phone {
    top: -12rem;
    max-height: 472px;
  }
  .categories {
    padding: 15rem 0 8rem;
  }
}

/* Bigger than 1000 */
@media (min-width: 1000px) {
  .section {
    padding: 20rem 0 19rem;
  }
  .hero {
    padding: 22rem 0;
  }
  .hero-heading {
    font-size: 4rem; 
    z-index:100;color:black;
  }
  .phone {
    top: -16rem;
    max-height: 615px;
  }
  .phone + .phone {
    top: -14rem;
    max-height: 570px;
  }
}
/**********************************/
@media (max-width:1375px){
  .container .row .one-half.column.phones{
  
}

}

.container .row .one-half.column.phones{
  
 width:700px;
  margin-left:350px;
  margin-top:-100px;
}
/**********************************/

.tint.two{
 
     position: absolute;
    left:110px;
    top: -250px;
    z-index:1;
}


.tint{
  position:relative;
  width:500px;
  height:400px;
  cursor: pointer;
  box-shadow: rgba(0,0,0,.2) 3px 5px 5px;
  overflow:hidden;
  z-index:6;

}
.tint.first{
  position:relative;
  bottom:150px;
  left:50px;
}
.tint img{
  height:500px;
  width:700px;
 
}
.tint:before{
  content: "";
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(210, 232, 232, 0.24);
  transition: all .3s linear;
}
.tint:hover:before,  
{ 

  background: none;  transform:scale(1.0);
    -ms-transform:scale(1.0);
    -moz-transform:scale(1.0);
    -webkit-transform:scale(1.0);
    -o-transform:scale(1.0);

     }



 .tint.first:hover img{
                /* Making images appear bigger and transparent on mouseover */
                cursor: pointer;
               transform:translateX(-30px);

      -webkit-transition: all 7s ease;
    -moz-transition: all 7s ease;
    -o-transition: all 7s ease;
    transition: all 7s ease;
  
     }
/*------------TINTS ON CLICK
-----------------------------------*/
     .tint.first.clicked{
      position:relative;
      top:-250px;
      left:-70%;

       z-index:100;
      box-shadow:none;
      background:transparent;
      width:140%;
      height:140%;
     -webkit-transform: rotate(360deg); /* Safari */
    transform: rotate(360deg);
    -webkit-transition:1.5s; 
 }
 .tint.first.clicked img{
  width:100%;
  height:100%;
 }

  .tint.first:hover.clicked img{
                /* Making images appear bigger and transparent on mouseover */
  transform:none;

     }

 /*************Background**/
.section.hero::after{ 
  content: "";
 background-image:url(../img/4.jpg);
opacity: 0.5;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;   

}
<link href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section hero">
    <div class="container">
      <div class="row">
        <div class="one-half column">
          <h4 class="hero-heading">
            Start enjoying your Photographs Now.  From anywhere.
          </h4>
          <a class="button button-primary" href=""target="_blank">Try it</a>
        </div>

        <div class="one-half column phones">
          
         
            <div class="tint first">
           <img src="http://img1.wikia.nocookie.net/__cb20140410195944/pokemon/images/archive/f/fc/20150101093541!025Pikachu_OS_anime_5.png">
             </div>
           
          
        
        </div>
      </div>
    </div>
  </div>

ไธบๆธ…ๆฅš่ตท่ง๏ผŒ่ฏทๆ‰“ๅผ€ๆˆ‘็š„codepenๅนถๆŒ‰็…งไปฅไธ‹่ฏดๆ˜Žๆ“ไฝœ๏ผš

1ใ€‚๏ผ‰ๅฐ†้ผ ๆ ‡ๆ‚ฌๅœๅœจๅ›พ็‰‡ไธŠๅนถ่ง‚ๅฏŸ็ฟป่ฏ‘ๆ‚ฌๅœๆ•ˆๆžœๅ’Œๅ›พ็‰‡ๆถˆๅคฑ็š„่‰ฒ่ฐƒใ€‚ ๏ผˆๆŒ‰้ข„ๆœŸๅทฅไฝœ๏ผ‰

2ใ€‚๏ผ‰็‚นๅ‡ปๅ›พ็‰‡๏ผŒ็‚นๅ‡ปๅŽไธ่ฆ็งปๅŠจ้ผ ๆ ‡๏ผŒ่ง‚ๅฏŸๅ›พ็‰‡ๅฆ‚ไฝ•ๆˆ้•ฟไธบๆก†ๆžถ

3.ใ€‚๏ผ‰้‡ๆ–ฐ็‚นๅ‡ปๅ›พ็‰‡ๆˆ–ๅชๆ˜ฏๅˆทๆ–ฐ้กต้ขไปฅๆขๅคๆญฃๅธธๅฐบๅฏธ๏ผŒ็Žฐๅœจ็‚นๅ‡ปๅ›พ็‰‡ๅนถ็ซ‹ๅณๅฐ†ๅ›พ็‰‡ไปŽๅ›พ็‰‡ไธŠ็งปๅˆฐๅ›พ็‰‡ไปฅๅค–็š„ไปปไฝ•ๅœฐๆ–นใ€‚

4ใ€‚๏ผ‰่ง‚ๅฏŸๅ›พ็‰‡ๅฆ‚ไฝ•่‡ชๅŠจ่ฟ‡ๆธกๅˆฐไธๅขž้•ฟ็š„ไฝ็ฝฎใ€‚

้—ฎ้ข˜๏ผš ๆฎๆˆ‘ๆ‰€็Ÿฅ๏ผŒ่ฟ™ๆ˜ฏๅ› ไธบโ€œ.tint.first๏ผšhover imgโ€ไป็„ถๆœ‰ๆ•ˆ๏ผŒๆˆ‘็Œœๆต‹ๅฆ‚ๆžœๆˆ‘็‚นๅ‡ปๅ›พ็‰‡ๅฐฑๅฏไปฅ็ฆ็”จๅฎƒ๏ผŒ้‚ฃๅฐฑๆฒก้—ฎ้ข˜ไบ†ใ€‚ๆˆ‘่ฏฅๆ€Žไนˆๅš๏ผŸ

ๅฆๅค–๏ผŒๅฆ‚ๆžœๆœ‰ไบบ่ƒฝๅ‘Š่ฏ‰ๆˆ‘ๅฆ‚ไฝ•ไฝฟๅ›พ็‰‡ๅ“ๅบ”๏ผŒ้‚ฃๅฐฑๅคชๅฅฝไบ†ใ€‚ๆˆ‘ๆ‹…ๅฟƒไฝ็ฝฎ๏ผš็›ธๅฏน๏ผŒ้กถ้ƒจ๏ผŒๅทฆไพง็ญ‰ๅœจๅ…ถไป–็ช—ๅฃไธŠไผšๆ˜ฏไป€ไนˆๆ ท็š„ใ€‚

2 ไธช็ญ”ๆกˆ:

็ญ”ๆกˆ 0 :(ๅพ—ๅˆ†๏ผš2)

ๆˆ‘ๅปบ่ฎฎๆ‚จๅœจ.tint.firstไธญๆทปๅŠ CSS๏ผšๅฐ†imgๆ‚ฌๅœๅˆฐ็ฑปไธญ๏ผŒ็„ถๅŽๆ นๆฎ้œ€่ฆๆทปๅŠ /ๅˆ ้™ค่ฏฅ็ฑปใ€‚

ๅœจๆ‚ฌๅœๆ—ถๆทปๅŠ ๅฎƒ๏ผŒ็‚นๅ‡ปๅฎƒๆฃ€ๆŸฅๅฎƒๆ˜ฏๅฆๅœจๅ…ƒ็ด ไธŠ่ฎพ็ฝฎๅนถๅˆ ้™คๅฎƒใ€‚ ๅœจmouseoutไธŠไฝ ๅ†ๆฌกๅœจๅ…ƒ็ด ไธŠ่ฎพ็ฝฎๅฎƒ๏ผˆไธ‹ๆฌกไฝ ๅธŒๆœ›ๅฎƒๅขž้•ฟ๏ผ‰ใ€‚

ๅธŒๆœ›ๆˆ‘ๅพˆๆธ…ๆฅšใ€‚

ๆญค่‡ด ่จๅฐ”

็ญ”ๆกˆ 1 :(ๅพ—ๅˆ†๏ผš0)

http://codepen.io/jzhang172/pen/YXoWZa

ๅทฅไฝœ็ญ”ๆกˆใ€‚ๅฝ“้ผ ๆ ‡่ฟ›ๅ…ฅๅŒบๅŸŸๆ—ถ๏ผŒๆทปๅŠ cssๅฑžๆ€ง๏ผŒๅฝ“้ผ ๆ ‡็ฆปๅผ€ๅŒบๅŸŸๆ—ถ๏ผŒๅˆ ้™ค่ฏฅcssๅฑžๆ€งใ€‚

๏ผ†๏ผƒ13;
๏ผ†๏ผƒ13;
$(function(){



$('.tint.first').mouseenter(function() {
	$(this).addClass("me img");
   
    
});
$('.tint.first').mouseleave(function() {
	$(this).removeClass("me img");
   
    
});

$('.tint.first').on('click', function() {
	$(this).removeClass("me img");
  $(this).toggleClass('clicked');
   
    
});


$('.tint.two').on('click', function() {
	$(this).toggleClass('clicked');
   
    
});
});
๏ผ†๏ผƒ13;
/* Shared
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.button {
  border-radius: 100px;
}

/* Sections
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.section {
  padding: 8rem 0 7rem;
  text-align: center;
}
.section-heading,
.section-description {
  margin-bottom: 1.2rem;
}

/* Hero
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.phones {
  position: relative;
}
.phone {
  position: relative;
  max-width: 80%;
  margin: 3rem auto -12rem;
}
.phone + .phone {
  display: none;
}

/* Values
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.values {
  background-image: url('../img/values-bg.jpg');
  background-size: cover;
  color: #fff;
  padding-bottom: 5rem;
}

.value-multiplier {
  margin-bottom: .5rem;
  color: #11DFC7;
}
.value-heading {
  margin-bottom: .3rem;
}
.value-description {
  opacity: .8;
  font-weight: 300;
}

/* Help
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.get-help {
  border-bottom: 1px solid #ddd;
}

/* Categories
โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“ */
.categories {
  background-image: url('../img/values-bg.jpg');
  background-size: cover;
  color: #fff;
}
.categories .section-description { 
  margin-bottom: 4rem;
}

/* Bigger than 550 */
@media (min-width: 550px) {
  .section {
    padding: 12rem 0 11rem;
  }
  .hero {
    padding-bottom: 12rem;
    text-align: left;
    height: 165px;
  }
  .phone {
    position: absolute;
    top: -7rem;
    right: 3rem;
    max-height: 362px;
    z-index: 3;
  }
  .phone + .phone {
    top: -6rem;
    display: block;
    max-width: 73.8%;
    right: 0;
    z-index: 2;
    max-height: 338px;
  }
  .hero-heading {
    font-size: 3.0rem;
    position:relative;
    z-index:100;
    color:black;
    font-weight:600;

  }
}

/* Bigger than 750 */
@media (min-width: 750px) {
  .hero {
    height: 190px;
  }
  .hero-heading {
    font-size: 3.2rem; z-index:100;color:black;
  }
  .section {
    padding: 14rem 0 15rem;
  }
  .hero {
    padding: 16rem 0 14rem;

  }
  .section-description {
    max-width: 60%;
    margin-left: auto;
    margin-right: auto;
  }
  .phone {
    top: -14rem;
    right: 5rem;
    max-height: 510px;
  }
  .phone + .phone {
    top: -12rem;
    max-height: 472px;
  }
  .categories {
    padding: 15rem 0 8rem;
  }
}

/* Bigger than 1000 */
@media (min-width: 1000px) {
  .section {
    padding: 20rem 0 19rem;
  }
  .hero {
    padding: 22rem 0;
  }
  .hero-heading {
    font-size: 4rem; 
    z-index:100;color:black;
  }
  .phone {
    top: -16rem;
    max-height: 615px;
  }
  .phone + .phone {
    top: -14rem;
    max-height: 570px;
  }
}
/**********************************/
@media (max-width:1375px){
  .container .row .one-half.column.phones{
  
}

}

.container .row .one-half.column.phones{
  
 width:700px;
  margin-left:350px;
  margin-top:-100px;
}
/**********************************/

.tint.two{
 
     position: absolute;
    left:110px;
    top: -250px;
    z-index:1;
}


.tint{
  position:relative;
  width:500px;
  height:400px;
  cursor: pointer;
  box-shadow: rgba(0,0,0,.2) 3px 5px 5px;
  overflow:hidden;
  z-index:6;

}
.tint.first{
  position:relative;
  bottom:150px;
  left:50px;
}
.tint img{
  height:500px;
  width:700px;
 
}
.tint:before{
  content: "";
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(210, 232, 232, 0.24);
  transition: all .3s linear;
}
.tint:hover:before,  
{ 

  background: none;  transform:scale(1.0);
    -ms-transform:scale(1.0);
    -moz-transform:scale(1.0);
    -webkit-transform:scale(1.0);
    -o-transform:scale(1.0);

     }



 .me img{
                /* Making images appear bigger and transparent on mouseover */
                cursor: pointer;
               transform:translateX(-30px);

      -webkit-transition: all 7s ease;
    -moz-transition: all 7s ease;
    -o-transition: all 7s ease;
    transition: all 7s ease;
  
     }
/*------------TINTS ON CLICK
-----------------------------------*/
     .tint.first.clicked{
      position:relative;
      top:-250px;
      left:-70%;

       z-index:100;
      box-shadow:none;
      background:transparent;
      width:140%;
      height:140%;
     -webkit-transform: rotate(360deg); /* Safari */
    transform: rotate(360deg);
    -webkit-transition:1.5s; 
 }
 .tint.first.clicked img{
  width:100%;
  height:100%;
 }

  .tint.first:hover.clicked img{
                /* Making images appear bigger and transparent on mouseover */
  transform:none;

     }

 /*************Background**/
.section.hero::after{ 
  content: "";
 background-image:url(../img/4.jpg);
opacity: 0.5;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  position: absolute;
  z-index: -1;   

}
๏ผ†๏ผƒ13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section hero">
    <div class="container">
      <div class="row">
        <div class="one-half column">
          <h4 class="hero-heading">
            Start enjoying your Photographs Now.  From anywhere.
          </h4>
          <a class="button button-primary" href=""target="_blank">Try it</a>
        </div>

        <div class="one-half column phones">
          
         
            <div class="tint first">
           <img src="http://img1.wikia.nocookie.net/__cb20140410195944/pokemon/images/archive/f/fc/20150101093541!025Pikachu_OS_anime_5.png">
             </div>
           
          
        
        </div>
      </div>
    </div>
  </div>
๏ผ†๏ผƒ13;
๏ผ†๏ผƒ13;
๏ผ†๏ผƒ13;

ๆœ€ๆ–ฐ้—ฎ้ข˜