项目设计到写个扇形的导航  弄了好久   记录一下

<body><div class="header-top"> </div><div class="container"> <svg id="svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="400px" height="400px"><defs><filter id="linear" x="0" y="0" width="200%" height="200%"><feOffset result="offOut" in=" " dx="20" dy="20" /><feGaussianBlur result="blurOut" in="offOut" stdDeviation="10" /><feBlend in="SourceGraphic" in2="blurOut" mode="normal" /></filter></defs><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><path class="paths" stroke="#068be7" stroke-width="1" fill="#000b40" filter="url(#linear)" /><foreignObject class='center'><a href=""><!-- <img src="t.png" /> --><img src="./img/center.png" alt=""></a></foreignObject><foreignObject class='list'><div><i class="fa fa-calendar" aria-hidden="true"></i><p>1</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-bell-o" aria-hidden="true"></i><p>2</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-calendar-plus-o" aria-hidden="true"></i><p>3</p>  </div></foreignObject><foreignObject class='list'><div><i class="fa fa-bus" aria-hidden="true"></i><p>4</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-desktop" aria-hidden="true"></i><p>5</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-edit" aria-hidden="true"></i><p>6</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-hdd-o" aria-hidden="true"></i><p>7</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-image" aria-hidden="true"></i><p>8</p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-calendar1" aria-hidden="true"></i><p>9/p></div></foreignObject><foreignObject class='list'><div><i class="fa fa-bell-o1" aria-hidden="true"></i><p>10</p></div></foreignObject></svg></div>
</body>
<script type="text/javascript">Object.defineProperties(window, {El: {value: function (el) {return document.querySelector(el)},enumerable: false},Els: {value: function (el) {return document.querySelectorAll(el)},enumerable: false}})init();window.onresize = function () {init();}function init() {//宽高为当前页面的40%El(".container").style.width = document.body.clientWidth * .8 + 'px';El(".container").style.height = document.body.clientWidth * .5 + 'px';var contW = El(".container").style.width,contH = El(".container").style.height;//svg自适应El("#svg").setAttribute('width', contW)El("#svg").setAttribute('height', contH)//中间图形自适应El(".center").setAttribute('x', (contW.split('px')[0] / 2 - contW.split('px')[0] / 4) - 150)El(".center").setAttribute('y', (contW.split('px')[0] / 2 - contW.split('px')[0] / 4) - 150)El(".center").setAttribute('width', (contW.split('px')[0] / 2) + 300)El(".center").setAttribute('height', (contW.split('px')[0] / 2) + 300)mkChart();}function mkChart() {//配置各种宽高var svgWsm = El("#svg").clientWidth - 100,svgHsm = El("#svg").clientHeight - 100,svgW2 = svgWsm / 2,svgH2 = svgWsm / 2,svgW = El("#svg").clientWidth,svgH = El("#svg").clientHeight,djx = Math.sqrt(Math.pow(svgW2, 2) + Math.pow(svgH2, 2)),djxW = Math.sqrt(Math.pow(djx - svgW2, 2) / 2);var ds = `M${svgW2 + 50} ${svgH2 + 50} L440 129 A ${svgW2} ${svgH2} 0 0 0 ${djxW + 50} ${djxW + 50} Z`;//循环扇形Els(".paths").forEach((item, index) => {item.setAttribute("d", ds);//自己旋转item.style.transform = `rotate(${18 * index - 45}deg)  `;item.style.transformOrigin = `${svgW2 + 50}px ${svgH2 + 50}px`;//触碰// item.onmouseenter = () => {//     //扇形放大//    item.style.transform = `rotate(${18*index-45}deg) scale(1.1)`;//     //里面内容同步放大//    Els('.list')[index].style.transform = `rotate(${15*index-55}deg) scale(1.05)`;// }// item.onmouseleave = () => {//    //还原//  item.style.transform = `rotate(${18*index-45}deg)`;//    Els('.list')[index].style.transform = `rotate(${15*index-55}deg)`;// }})//循环扇形内容Els('.list').forEach((item, index) => {//自己旋转item.style.transform = `rotate(${18 * index - 77}deg)   `;item.style.transformOrigin = `${svgW2 + 50}px ${svgH2 + 50}px`;//子元素反旋转显示正位item.children[0].style.transform = `rotate(${-18 * index + 77}deg)`;//触碰item.onmouseenter = () => {//外层同步放大Els('.paths')[index].style.transform = `rotate(${18 * index - 45}deg) scale(1.05)`;//内层放大item.style.transform = `rotate(${18 * index - 77}deg) ) scale(1)`;}item.onmouseleave = () => {//还原Els('.paths')[index].style.transform = `rotate(${18 * index - 45}deg) `;item.style.transform = `rotate(${18 * index - 77}deg) `;}//里面的位置item.setAttribute('x', svgW / 2 - svgW / 9);item.setAttribute('y', svgH / 10);item.setAttribute('width', svgW / 6);item.setAttribute('height', svgH / 4);})//中间事件// El(".center>a").onclick = () => {//  alert("中间事件")// }}</script>
* {margin: 0;padding: 0;}
body{background:url("../img/u50_state0.jpg") no-repeat center #0b1341 ;background-size: cover;height: 100vh;overflow: hidden;
position: relative;
}.container {position: absolute;right: 0;left: 0;bottom: -60px;margin: auto;}.header-top{width: 100%;height: 100px;position: absolute;background:url("../img/u52.png") no-repeat center ;background-size: cover;text-align: center;color: #fff;line-height: 58px;font-size: 30px;font-weight: bold;
}#svg path {transition: transform .2s;color: white;cursor: pointer;
}#svg .center {border-radius: 50%; }#svg .center img {width: 100%;height: 100%;
}#svg .list {transition: transform .2s;cursor: pointer;/* background: url("../img/bj.png") no-repeat center;background-size: contain;  */
}#svg .list div {text-align: center;color: #589bfc;padding: 20px 70px;display: flex;flex-direction: column;justify-content: center;align-items: center;
}
#svg .list div a{color: #589bfc;text-decoration: none;
}.fa{width: 50px;height: 50px;margin-bottom: 5px;
}

扇形导航 html svg相关推荐

  1. html的扇形代码导航,CSS3--利用transform和transition属性制作扇形导航

    在前面,我们已经讲解了transform这个属性以及案例,那么本文会进一步结合transform和transition两个属性,并制作一个简单的案例进行说明. 一.transition属性说明 接下来 ...

  2. html5 扇形导航效果图,js+css实现扇形导航效果

    本文实例为大家分享了js+css实现扇形导航效果的具体代码,供大家参考,具体内容如下\ 扇形导航 *{ margin: 0; padding: 0; } html,body{ height: 100% ...

  3. web前端:扇形导航,三角函数sinθ对边x轴,cosθ邻边y轴计算原生实现

    1.三角函数原理分析 2.less定义布局 * {margin: 0;padding: 0;//找子选择器css:#id > .class {}body {//取消滚动条显示height: 10 ...

  4. android底部导航栏svg,vue开发移动端底部导航条功能

    效果图 src/app.vue 头部导航 内容区域 import Tabbar from 'components/tabbar'; export default { name: 'App', comp ...

  5. java 扇形_扇形导航 css3

    本篇文章将通过对css3中的2d变化以及过渡进行分析设计 先放上最终效果图 功能实现:1.给扇形home元素设置点击事件并添加2d旋转 2.给导航栏设置2d旋转 并通过三角函数计算出各个导航位置 3. ...

  6. html3d扇形菜单,扇形菜单特效

    扇形导航 *{ margin: 0; padding: 0; } a { text-align: right; text-decoration: none; color: #000 !importan ...

  7. HTML5和CSS3一些基本概括

    html5 1.新增了语义化标签 语言,语义.语言的意义就是标签的意义 意思就是这个标签的单词的意思就是他在页面中所充当角色的意思 header 头部 nav 导航 main 主要内容 footer ...

  8. 前端HTML5视频_CSS3-张晓飞-专题视频课程

    前端HTML5视频_CSS3-305人已学习 课程介绍         本套视频旨在向学员全面剖析css3中的新增的各类属性与方案.深入了解预处理less,并从源码的角度解读bootstrap相关实现 ...

  9. HTML 框架、列表和table标签练习 第二个模块2

    HTML 框架和table标签练习 HTML 框架 iframe标签 案例07 HTML 列表 无序列表 案例08 有序列表 列表嵌套 案例9 作业 作业1制作方块导航器 作业2使用table实现如下 ...

最新文章

  1. 【数据结构】之算法效率的度量
  2. Linux基础 —— Linux终端命令格式
  3. 错误信息Make an entry in Field Text Area
  4. mongo执行逻辑表达式_MongoDB 常用查询操作
  5. android开花动画,15款界面最漂亮Android应用程序揭晓
  6. C++ getline在VC6.0的一个bug(处理方法)(转)
  7. axios拦截器_77.9KStar 的 Axios 项目有哪些值得借鉴的地方
  8. NAS远程共享存储NFS
  9. Delta并联机构在ADAMS仿真中的运动副设置(二)
  10. 阿里云企业邮箱标准版多域名绑定
  11. 当div的宽度为百分比时,如何设置成为一个正方形?
  12. PC上无法捕捉vlan tag的原因
  13. 做视频自媒体,选择一个合适的剪辑软件很重要,这些或许适合你
  14. 史上最强模型 GPT-4 上线:一张手绘草图能生一个网站、60 秒搞定一个游戏开发!
  15. 前端案例:蓝色CSS3二级导航菜单
  16. 三极管为什么可以放大电流?
  17. RED LION 1GS00000
  18. 微信网页授权校验文件
  19. python多窗口传递信息_PyQT5 中两个界面之间数据传递
  20. 二叉树的叶子结点按从左到右的顺序连成一个单链表

热门文章

  1. 微信小程序之身份证照片正反上传
  2. CSS前端样式美化总结
  3. 水晶报表中如何创建自定义的纸张大小格式?
  4. 网易新财报:游戏养家,教育维稳、音乐快走
  5. 钢条切割问题(动态规划)
  6. 钢条切割问题(自顶向下)
  7. Pygame显示文字
  8. 最好的贵人,是努力的自己
  9. 数据分析Excel必备技能:数据透视表使用教程
  10. 从技术角度告诉你,区块链到底有哪些特点和运作机制