CSS3 滑鼠懸浮立體翻滾的導航選單

admin發表於2017-05-04

分享一段程式碼例項,它實現了滑鼠懸浮能夠立體翻滾的導航選單效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
*{
  margin: 0;
  padding: 0;
}
ul{
  width: 1000px;
  list-style: none;
  margin: 100px auto;
}
li{
  width: 100px;
  height: 40px;
  float: left;
  /*border: 1px solid #000;*/
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
  transition: all 1s;
}
span{
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  text-align: center;
  line-height: 40px;
}
span:nth-child(1){
  background-color: red;
  transform:translateZ(20px) ;
}
span:nth-child(2){
  background-color: green;
  transform:rotateX(90deg) translateZ(20px) ;
}
ul:hover li{
  transform: rotateX(-90deg);
}
li:nth-child(2){
  transition-delay: 0.2s;
}
li:nth-child(3){
  transition-delay: 0.3s;
}
li:nth-child(4){
  transition-delay: 0.4s;
}
li:nth-child(5){
  transition-delay: 0.5s;
}
</style>
</head>
<body>
<ul>
  <li>
    <span>螞蟻部落</span>
    <span>螞蟻部落一</span>
  </li>
  <li>
    <span>螞蟻部落</span>
    <span>螞蟻部落二</span>
  </li>
  <li>
    <span>螞蟻部落</span>
    <span>螞蟻部落三</span>
  </li>
  <li>
    <span>螞蟻部落</span>
    <span>螞蟻部落四</span>
  </li>
  <li>
    <span>螞蟻部落</span>
    <span>螞蟻部落五</span>
  </li>
</ul>
</body>
</html>

相關文章