一種新的隱藏-顯示模式誕生——css3的scale(0)到scale(1)


.dropdown-menu {
  background: rgba(255, 255, 255, 0.98) none repeat scroll 0 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  left: 50%;
  padding: 20px;
  position: absolute;
  text-transform: uppercase;
  top: 68px;
  transform-origin: center top 0;
  z-index: 3;
//  display: none;
  transform:scale(0);                                          //隱藏下拉菜單取代display:none;
  -webkit-transition:all .6s ease 0s;
  transition:all .6s ease 0s;
}

.nav-menu>ul>li:hover .dropdown-menu{                 //滑過li時子元素下拉菜單顯示成等比1:1比例,緩動顯示
  transform:scale(1);
}

.nav-menu>ul>li:hover a::before{         //滑過父元素導航項li時,下划線等比顯示
//  animation:underline1 0.5s ease 0s normal forwords 1 runing ;//animation-fill-mode:forwords讓動畫停留在最后的狀態(both參數的意思是停在最后的狀態或初始狀態)  后面的1是指只循環一次
//  background: #333 none repeat scroll 0 0;
//  bottom: -2px;
//  content: "";
//  height: 2px;
//  position: absolute;
  transform:scale(1);
}

注意:用css3的動畫取代jquery邏輯可以完美的展現下拉菜單鼠標進出的邏輯,jquery則比較麻煩,這個邏輯css3完成的比較好。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM