CSS3 扇形導航選單程式碼例項

admin發表於2017-06-01

分享一段程式碼例項,它利用css3實現了扇形導航選單效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
#sector {
  position: relative;
  overflow: hidden;
  width: 200px;
  height: 100px;
  margin: 150px auto;
  background-color: #ddd;
  border-top-left-radius: 100px;
  border-top-right-radius: 100px;
}
#sector ul li {
  list-style: none;
  position: absolute;
  width: 200px;
  height: 100px;
  right: 50%;
  top: 0;
  transform-origin: 100% 100%;
}
#sector .sector1 {
  background-color: #fef4ac;
  transform: skew(54deg);
}
#sector .sector2 {
  background-color: #FCF6E6;
  transform: rotate(36deg) skew(54deg);
}
#sector .sector3 {
  background-color: #faf2cc;
  transform: rotate(72deg) skew(54deg);
}
#sector .sector4 {
  background-color: #f9f1e9;
  transform: rotate(108deg) skew(54deg);
}
#sector .sector5 {
  background-color: #f5e79e;
  transform: rotate(144deg) skew(54deg);
}
#sector ul li p {
 position: absolute;
  top: 50px;
  left: 150px;
  transform: skew(-54deg) rotate(-70deg);
}
</style>
</head>
<body>
  <div id="sector">
    <ul>
      <li class="sector1">
        <p>A</p>
      </li>
      <li class="sector2">
        <p>B</p>
      </li>
      <li class="sector3">
        <p>C</p>
      </li>
      <li class="sector4">
        <p>D</p>
      </li>
      <li class="sector5">
        <p>E</p>
      </li>
    </ul>
    <a></a>
  </div>
</body>
</html>

相關文章