使用css 实现动感菜单

  • html
 <nav>
    <ul>
      <li><span>1</span></li>
      <li><span>2</span></li>
      <li><span>3</span></li>
      <li><span>4</span></li>
      <li><span>5</span></li>
      <li><span>6</span></li>
      <li><span>7</span></li>
      <li><span>8</span></li>
      <li><span>9</span></li>
    </ul>
  </nav>

 

  • css
body{
  margin: 0;
}
ul{
  list-style: none;
  margin: 0;
  padding: 0;
}

nav{
  width: 400px;
  height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  border: 1px solid #000;
}
nav::before{
  position: absolute;
  content: '';
  width: 200px;
  height:200px;
  background: #987;
  border-radius: 50%;
  z-index: 1;
}
nav::after{
  position: absolute;
  content: '菜单';
  color: #fff;
  font-size: 22px;
  z-index: 1;
}
nav:hover ul {
  transform: scale(1);
}

ul {
  width: 300px;
  height: 300px;
  transform: scale(0);
  transition: .5s;
}


ul li{
  width: 80px;
  height: 80px;
  background: #879;
  border-radius:50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color:#fff;
  font-size: 24px;
  position: absolute;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
  transform-origin: 150px 150px;
  transition: all 1s ease;
}
ul li span{
  transition: all 1s;
}
nav:hover ul li:nth-of-type(1){
  transform: rotate(40deg);
}
nav:hover ul li:nth-of-type(1)>span{
  transform: rotate(-40deg);
}
nav:hover ul li:nth-of-type(2){
  transform: rotate(80deg);
}
nav:hover ul li:nth-of-type(2)>span{
  transform: rotate(-80deg);
}
nav:hover ul li:nth-of-type(3){
  transform: rotate(120deg);
}
nav:hover ul li:nth-of-type(3)>span{
  transform: rotate(-120deg);
}
nav:hover ul li:nth-of-type(4){
  transform: rotate(160deg);
}
nav:hover ul li:nth-of-type(4)>span{
  transform: rotate(-160deg);
}
nav:hover ul li:nth-of-type(5){
  transform: rotate(200deg);
}
nav:hover ul li:nth-of-type(5)>span{
  transform: rotate(-200deg);
}
nav:hover ul li:nth-of-type(6){
  transform: rotate(240deg);
}
nav:hover ul li:nth-of-type(6)>span{
  transform: rotate(-240deg);
}
nav:hover ul li:nth-of-type(7){
  transform: rotate(280deg);
}
nav:hover ul li:nth-of-type(7)>span{
  transform: rotate(-280deg);
}
nav:hover ul li:nth-of-type(8){
  transform: rotate(320deg);
}
nav:hover ul li:nth-of-type(8)>span{
  transform: rotate(-320deg);
}
nav:hover ul li:nth-of-type(9){
  transform: rotate(360deg);
}
nav:hover ul li:nth-of-type(9)>span{
  transform: rotate(-360deg);
}


 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值