黑松山资源网 Design By www.paidiu.com
本文介绍了css3实现元素环绕中心点布局的方法示例,分享给大家,具体如下:
效果如图:
代码实现:
<style> *{ margin: 0; padding: 0; box-sizing: border-box; } .surround-box, .center-point{ position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin-left: -10px; margin-top: -10px; border-radius: 50%; background-color: #000; } .circle{ /* 这里一定要绝对定位,这样位置才能铺开来 */ position: absolute; top: -10px; left: -10px; width: 40px; height: 40px; line-height: 40px; border-radius: 50%; text-align: center; color: #fff; } .circle1{ background-color: red; /* rotateZ控制方向,每个元素旋转30度,12个元素刚好360度。translateY控制每个元素距中心点的距离 */ transform: rotateZ(30deg) translateY(80px); } .circle2{ background-color: orange; transform: rotateZ(60deg) translateY(80px); } .circle3{ background-color: yellow; transform: rotateZ(90deg) translateY(80px); } .circle4{ background-color: green; transform: rotateZ(120deg) translateY(80px); } .circle5{ background-color: seagreen; transform: rotateZ(150deg) translateY(80px); } .circle6{ background-color: blue; transform: rotateZ(180deg) translateY(80px); } .circle7{ background-color: purple; transform: rotateZ(210deg) translateY(80px); } .circle8{ background-color: lightsalmon; transform: rotateZ(240deg) translateY(80px); } .circle9{ background-color: deeppink; transform: rotateZ(270deg) translateY(80px); } .circle10{ background-color: lightyellow; transform: rotateZ(300deg) translateY(80px); } .circle11{ background-color: lightgreen; transform: rotateZ(330deg) translateY(80px); } .circle12{ background-color: lightslategrey; transform: rotateZ(360deg) translateY(80px); } </style>
<body> <div class="center-point"></div> <div class="surround-box"> <div class="circle circle1">1</div> <div class="circle circle2">2</div> <div class="circle circle3">3</div> <div class="circle circle4">4</div> <div class="circle circle5">5</div> <div class="circle circle6">6</div> <div class="circle circle7">7</div> <div class="circle circle8">8</div> <div class="circle circle9">9</div> <div class="circle circle10">10</div> <div class="circle circle11">11</div> <div class="circle circle12">12</div> </div> </body>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 《地狱潜者2》玩家人数飙升:终于不再削弱玩家了
- 黑神话引力!外媒分享孙悟空英文书籍:美生中国人等
- 《荒野大镖客》PC版曝光!《GTA6》疑似也有PC版
- 林宥嘉.2008-神秘嘉宾(引进版)【华研国际】【WAV+CUE】
- 徐小凤.1997-金曲精选(康艺经典珍藏系列)【康艺成音】【WAV+CUE】
- 群星.1994-非常精丫宝丽金】【WAV+CUE】
- 《赛马娘 热血喧闹大感谢祭!》评测:现代复古派对
- 《星球大战:亡命之徒》评测:还是看看远方的光剑吧
- 《末日地带2》评测:酣畅淋漓的“和面”之旅
- 交错战线研发中心推荐角色一览
- 交错战线合成工厂推荐角色一览
- 战锤40K星际战士2狙击职业介绍|狙击职业技能效果一览
- RobertSaxtonTheResurrectionoftheSoldiers(2024)[24Bit-192kHz]FLAC
- 唐成杨东哥弹唱《情若真HQ》头版限量编号[WAV+CUE]
- 柏菲·HIFI风情1《一杯香茶》限量开盘母带ORMCD[WAV+CUE]