CSS3技術讓網頁設計更加靈活,其中圓形菜單就是它的一大亮點。
.menu { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); } .menu ul { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; padding: 0; list-style: none; } .menu ul li { width: 50px; height: 50px; margin: 10px; background-color: #333; border-radius: 50%; transition: all 0.3s ease; transform: translateX(-100%); display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; cursor: pointer; } .menu ul li:hover { background-color: #666; } .menu:hover ul li { transform: translateX(0); } .menu:hover ul li:nth-of-type(1) { transition-delay: 0.1s; } .menu:hover ul li:nth-of-type(2) { transition-delay: 0.2s; } .menu:hover ul li:nth-of-type(3) { transition-delay: 0.3s; } .menu:hover ul li:nth-of-type(4) { transition-delay: 0.4s; } .menu:hover ul li:nth-of-type(5) { transition-delay: 0.5s; }
這段代碼實現(xiàn)了一個簡單的圓形菜單,其中用到了CSS3中的Flex布局和過渡效果。通過懸浮在菜單上,可以將菜單項展開。