码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • uni-app:实现图片周围的图片按照圆进行展示


    效果

    代码

    1. <template>
    2. <view class="position">
    3. <view class="circle">
    4. <img src="/static/item1.png" class="center-image">
    5. <view v-for="(item, index) in itemList" :key="index" class="item" :style="getItemStyle(index)">
    6. <img :src="item.src" />
    7. <text>{{ item.name }}text>
    8. view>
    9. view>
    10. view>
    11. template>
    12. <script>
    13. export default {
    14. data() {
    15. return {
    16. itemList: [{
    17. name: "Item1",
    18. src: "/static/item1.png"
    19. },
    20. {
    21. name: "Item2",
    22. src: "/static/item2.png"
    23. },
    24. {
    25. name: "Item3",
    26. src: "/static/item3.png"
    27. },
    28. {
    29. name: "Item4",
    30. src: "/static/item4.png"
    31. },
    32. {
    33. name: "Item5",
    34. src: "/static/item5.png"
    35. },
    36. {
    37. name: "Item6",
    38. src: "/static/item6.png"
    39. },
    40. {
    41. name: "Item7",
    42. src: "/static/item7.png"
    43. },
    44. ],
    45. circleRadius: 120, // 圆的半径
    46. itemSize: 60, // 每个view的大小
    47. };
    48. },
    49. methods: {
    50. // 计算每个 view 的样式
    51. getItemStyle(index) {
    52. const {
    53. itemList,
    54. circleRadius,
    55. itemSize
    56. } = this;
    57. const angle = (2 * Math.PI) / itemList.length; // 每个 view 的角度间隔
    58. const centerX = circleRadius + itemSize / 2; // 圆心的 x 坐标
    59. const centerY = circleRadius + itemSize / 2; // 圆心的 y 坐标
    60. const radius = circleRadius + itemSize / 2; // view 的圆心距离(圆的半径加上 view 大小的一半)
    61. const x = Math.round(centerX + radius * Math.cos(angle * index - Math.PI / 2)); // 计算 x 坐标
    62. const y = Math.round(centerY + radius * Math.sin(angle * index - Math.PI / 2)); // 计算 y 坐标
    63. return {
    64. width: itemSize + "px",
    65. height: itemSize + "px",
    66. position: "absolute",
    67. top: y + "px",
    68. left: x + "px",
    69. transform: `translate(-50%, -50%)`, // 居中显示
    70. };
    71. },
    72. },
    73. };
    74. script>
    75. <style scoped>
    76. /* 整体位置 */
    77. .position{
    78. /* border: 1px solid black; */
    79. position: absolute;
    80. top:50%;
    81. left:50%;
    82. transform: translate(-50%, -50%);
    83. }
    84. /* 圆的样式 */
    85. .circle {
    86. width: 300px;
    87. height: 300px;
    88. border-radius: 50%;
    89. /* border: 1px solid black; */
    90. }
    91. /* 中间图标 */
    92. .center-image {
    93. width: 80px;
    94. height: 80px;
    95. position: absolute;
    96. top: 50%;
    97. left: 50%;
    98. transform: translate(-50%, -50%);
    99. }
    100. /* 小图标 */
    101. .item {
    102. display: flex;
    103. flex-direction: column;
    104. align-items: center;
    105. justify-content: center;
    106. text-align: center;
    107. }
    108. /* 小图标的图片信息 */
    109. .item img {
    110. width: 40px;
    111. height: 40px;
    112. border-radius: 50%;
    113. }
    114. style>

  • 相关阅读:
    基于xsh的vbs脚本的使用(简介)
    算法竞赛入门【码蹄集新手村600题】(MT1151-1200)
    OpenFeign
    Win10自动更新之后很卡怎么办?
    C语言的stdio.h的介绍
    智源社区周刊:Yann LeCun撰文预测自主智能发展;NYU学者认为通用人工智能的讨论没有意义...
    C++STL详解(五)map&set的使用及其模拟实现
    GameFrameWork框架(Unity3D)使用笔记(六)游戏主流程ProcedureMain——从数据表加载出所需实体
    生信云实证Vol.12:王者带飞LeDock!开箱即用&一键定位分子库+全流程自动化,3.5小时完成20万分子对接
    人工智能-卷积神经网络之多输入多输出通道
  • 原文地址:https://blog.csdn.net/weixin_46001736/article/details/133276235
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号