svg+css实现悬浮九宫格图标菜单显示效果代码
代码语言:html
所属分类:菜单导航
代码描述:svg+css 实现悬浮九宫格图标菜单显示效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> <style> body{ margin: 100px; } .main_back { position: absolute; border-radius: 10px; transform: rotate(90deg); width: 11em; height: 11em; background: linear-gradient(270deg, #03a9f4, #cc39a4, #ffb5d2); z-index: -2; box-shadow: inset 0px 0px 180px 5px #ffffff; } .main { display: flex; flex-wrap: wrap; width: 14em; align-items: center; justify-content: center; z-index: -1; } .card { width: 60px; height: 60px; border-top-left-radius: 10px; background: lightgrey; transition: .4s ease-in-out, .2s background-color ease-in-out, .2s background-image ease-in-out; background: rgba(255, 255, 255, 0.596); backdrop-filter: blur(5px); border: 1px solid transparent; -webkit-backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; } .card .instagram { opacity: 0; transition: .2s ease-in-out; fill: #cc39a4; } .card:nth-child(2) { border-radius: 0px; } .card:nth-child(2) .twitter { opacity: 0; transition: .2s ease-in-out; fill: #03A9F4; } .card:nth-child(3) { border-top-right-radius: 10px; border-top-left-radius: 0px; } .card:nth-child(3) .dribble { opacity: 0; transition: .2s ease-in-out; fill: #ffb5d2; } .card:nth-child(4) { border-radius: 0px; } .card:nth-child(4) .codepen { opacity: 0; transition: .2s ease-in-out; fill: black; } .card:nth-child(5) { border-radius: 0px; } .card:nth-child(5) .uiverse { position: absolute; margin-left: 0.2em; margin-top: 0.2em; opacity: 0; transition: .2s ease-in-out; } .card:nth-child(6) { border-radius: 0px; } .card:nth-child(6) .discord { opacity: 0; transition: .2s ease-in-out; fill: #8c9eff; } .card:nth-child(7) { border-bottom-left-radius: 10px; border-top-left-radius: 0px; } .card:nth-child(7) .github { opacity: 0; transition: .2s ease-in-out; fill: black; } .card:nth-child(8) { border-radius: 0px; } .card:nth-child(8) .telegram { opacity: 0; transition: .2s ease-in-out; fill: #29b6f6; } .card:nth-child(9) { border-bottom-right-radius: 10px; border-top-left-radius: 0px; } .card:nth-child(9) .reddit { opacity: 0; transition: .2s ease-in-out; } .main:hover { width: 14em; cursor: pointer; } .main:hover .main_back { opacity: 0; } .main:hover .card { margin: .2em; border-radius: 10px; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.2); } .main:hover .card:nth-child(5) { border: transparent; } .main:hover .text { opacity: 0; z-index: -3; } .main:hover .instagram { opacity: 1; } .main:hover .twitter { opacity: 1; } .main:hover .dribble { opacity: 1; } .main:hover .codepen { opacity: 1; } .main:hover .uiverse { opacity: 1; } .main:hover .discord { opacity: 1; } .main:hover .github { opacity: 1; } .main:hover .telegram { opacity: 1; } .main:hover .reddit { opacity: 1; } .card:nth-child(1):hover { background-color: #cc39a4; } .card:nth-child(1):hover .instagram { fill: white; } .card:nth-child(2):hover { background-color: #03A9F4; } .card:nth-child(2):hover .twitter { fill: white; } .card:nth-child(3):hover { background-color: #ffb5d2; } .card:nth-child(3):hover .dribble { fill: white; } .card:nth-child(4):hover { background-color: #1E1F26; } .card:nth-child(4):hover .codepen { fill: white; } .card:nth-child(5):hover { animation: backgroundIMG .1s; animation-fill-mode: forwards; } .card:nth-child(5):hover .uiverse #paint0_linear_501_142 stop { stop-color: white; } .card:nth-child(5):hover .uiverse #paint1_linear_501_142 stop { stop-color: white; } .card:nth-child(5):hover .uiverse #paint2_linear_501_142 stop { stop-color: white; } @keyframes backgroundIMG { 100% { background-image: linear-gradient(#BF66FF,#6248FF,#00DDEB); } } .card:nth-child(6):hover { background-color: #8c9eff; } .card:nth-child(6):hover .discord { fill: white; } .card:nth-child(7):hover { background-color: black; } .card:nth-child(7):hover .github { fill: white; } .card:nth-child(8):hover { background-color: #29b6f6; } .card:nth-child(8):hover .telegram > path:nth-of-type(1) { fill: white; } .card:nth-child(8):hover .telegram > path:nth-of-type(2) { fill: #29b6f6; } .card:nth-child(8):hover .telegram > path:nth-of-type(3) { fill: #29b6f6; } .card:nth-child(9):hover { background-color: rgb(255,69,0); } .card:nth-child(9) .reddit > g circle { fill: rgb(255,69,0); } .card:nth-child(9) .reddit > g path { fill: white; } .text { position: absolute; font-size: 0.7em; transition: .4s ease-in-out; color: black; text-align: center; font-weight: bold; letter-spacing: 0.33em; z-index: 3; } </style> </head> <body> <div class="main"> <div class="card"> <svg class="instagram" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,256,256" width="30px" height="30px" fill-rule="nonzero"><g fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(8,8)"><path d="M11.46875,5c-3.55078,0 -6.46875,2.91406 -6.46875,6.46875v9.0625c0,3.55078 2.91406,6.46875 6.46875,6.46875h9.0625c3.55078,0 6.46875,-2.91406 6.46875,-6.46875v-9.0625c0,-3.55078 -2.91406,-6.46875 -6.46875,-6.46875zM11.46875,7h9.0625c2.47266,0 4.46875,1.99609 4.46875,4.46875v9.0625c0,2.47266 -1.99609,4.46875 -4.46875,4.46875h-9.0625c-2.47266,0 -4.46875,-1.99609 -4.46875,-4.46875v-9.0625c0,-2.47266 1.99609,-4.46875 4.46875,-4.46875zM21.90625,9.1875c-0.50391,0 -0.90625,0.40234 -0.90625,0.90625c0,0.50391 0.40234,0.90625 0.90625,0.90625c0.50391,0 0.90625,-0.40234 0.90625,-0.90625c0,-0.50391 -0.40234,-0.90625 -0.90625,-0.90625zM16,10c-3.30078,0 -6,2.69922 -6,6c0,3.30078 2.69922,6 6,6c3.30078,0 6,-2.69922 6,-6c0,-3.30078 -2.69922,-6 -6,-6zM16,12c2.22266,0 4,1.77734 4,4c0,2.22266 -1.77734,4 -4,4c-2.22266,0 -4,-1.77734 -4,-4c0,-2.22266 1.77734,-4 4,-4z"></path></g></g></svg> </div> <div class="card"> <svg class="twitter" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="30px" height="30px"><path d="M42,12.429c-1.323,0.586-2.746,0.977-4.247,1.162c1.526-0.906,2.7-2.351,3.251-4.058c-1.428,0.837-3.01,1.452-4.693,1.776C34.967,9.884,33.05,9,30.926,9c-4.08,0-7.387,3.278-7.387,7.32c0,0.572,0.067,1.129,0.193,1.67c-6.138-0.308-11.582-3.226-15.224-7.654c-0.64,1.082-1,2.349-1,3.686c0,2.541,1.301,4.778,3.285,6.096c-1.211-0.037-2.351-0.374-3.349-0.914c0,0.022,0,0.055,0,0.086c0,3.551,2.547,6.508,5.923,7.181c-0.617,0.169-1.269,0.263-1.941,0.263c-0.477,0-0.942-0.054-1.392-0.135c0.94,2.902,3.667,5.023,6.898,5.086c-2.528,1.96-5.712,3.134-9.174,3.134c-0.598,0-1.183-0.034-1.761-0.104C9.268,36.786,13.152,38,17.321,38c13.585,0,21.017-11.156,21.017-20.834c0-0.317-0.01-0.633-0.025-0.945C39.763,15.197,41.013,13.905,42,12.429"></path></svg> </div> <div class="card"> <svg class="dribble" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="30px" height="30px"><path d="M20,38.5C9.799,38.5,1.5,30.201,1.5,20S9.799,1.5,20,1.5S38.5,9.799,38.5,20S30.201,38.5,20,38.5z"></path><path fill="#ea4c89" d="M20,2c9.925,0,18,8.075,18,18s-8.075,18-18,18S2,29.925,2,20S10.075,2,20,2 M20,1 C9.507,1,1,9.507,1,20s8.507,19,19,19s19-8.507,19-19S30.493,1,20,1L20,1z"></path><path fill="none" stroke="#ea4c89" stroke-miterlimit="10" d="M28.352 36.914c0 0-3.032-21.087-15.63-34.292M1.269 17.848c0 0 24.2 2.117 32.075-11.102M7.804 34.152c0 0 8.624-19.807 31.058-12.194"></path></svg> </div> <div class="card"> <svg class="codepen" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="30px" height="30px"><path d="M 25 4 L 4 17.34375 L 4 32.652344 L 25 46 L 46 32.65625 L 46 17.34375 Z M 25 29.183594 L 19.066406 25.070313 L 25 21.023438 L 30.933594 25.070313 Z M 27 17.605469 L 27 9.949219 L 40.429688 18.484375 L 34.410156 22.65625 Z M 23 17.605469 L 15.589844 22.65625 L 9.570313 18.484375 L 23 9.949219 Z M 12.09375 25.042969 L 8 27.832031 L 8 22.2031.........完整代码请登录后点击上方下载按钮下载查看
网友评论0