HTML怎么实现这种椭圆形布局?
如图,就是中间是一张会议桌图片,然后再这个图片周围渲染多个可以点击的座位
https://codepen.io/FractalPen/pen/BaVWMKd
--sin
的值偏经验主义
.flex-row {display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;}
.flex-row > .flex-main {-webkit-flex:1 1 auto;flex:1 1 auto;}
.flex-row > .flex-side {-webkit-flex:0 0 auto;flex:0 0 auto;}
.flex-column {display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;}
.flex-column > .flex-main {-webkit-flex:1 1 auto;flex:1 1 auto;}
.flex-column > .flex-side {-webkit-flex:0 0 auto;flex:0 0 auto;}
.cell {margin:0.5em;width:3em;height:3em;line-height:3em;text-align:center;border-radius:50%;box-shadow:0 0 0 1px #000 inset;}
.cell-left {margin-left:calc(var(--r) * var(--sin));}
.cell-right {margin-right:calc(var(--r) * var(--sin));align-self:end;}
<div class="flex-row">
<div class="flex-side flex-column" style="--r:8em;justify-content:center;">
<div class="flex-side cell cell-left" style="--sin:0.8;">L</div>
<div class="flex-side cell cell-left" style="--sin:0.3;">L</div>
<div class="flex-side cell cell-left" style="--sin:0;">L</div>
<div class="flex-side cell cell-left" style="--sin:0;">L</div>
<div class="flex-side cell cell-left" style="--sin:0.3;">L</div>
<div class="flex-side cell cell-left" style="--sin:0.8;">L</div>
</div>
<div class="flex-side flex-column">
<div class="flex-side flex-row" style="justify-content:space-between;">
<div class="flex-side cell">T</div>
<div class="flex-side cell">T</div>
<div class="flex-side cell">T</div>
<div class="flex-side cell">T</div>
<div class="flex-side cell">T</div>
</div>
<div class="flex-main"></div>
<div class="flex-side flex-row" style="justify-content:space-between;">
<div class="flex-side cell">B</div>
<div class="flex-side cell">B</div>
<div class="flex-side cell">B</div>
<div class="flex-side cell">B</div>
<div class="flex-side cell">B</div>
</div>
</div>
<div class="flex-side flex-column" style="--r:8em;justify-content:center;">
<div class="flex-side cell cell-right" style="--sin:0.8">R</div>
<div class="flex-side cell cell-right" style="--sin:0.3">R</div>
<div class="flex-side cell cell-right" style="--sin:0">R</div>
<div class="flex-side cell cell-right" style="--sin:0">R</div>
<div class="flex-side cell cell-right" style="--sin:0.3">R</div>
<div class="flex-side cell cell-right" style="--sin:0.8">R</div>
</div>
</div>
6 回答2.9k 阅读✓ 已解决
8 回答4.6k 阅读✓ 已解决
6 回答3.3k 阅读✓ 已解决
5 回答2.8k 阅读✓ 已解决
6 回答2.3k 阅读
5 回答6.3k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
可以用
offset-path
和offset-distance
来实现,好处是位置可以自动分配,无需单独计算path
可以通过一般的设计软件生成svg
,然后将svg
转换成path
转换地址:https://www.zhangxinxu.com/sp...
这里做了一个简单的示例:https://runjs.work/projects/7...
可以自己适当修改,之前在这篇文章中有相关技巧:https://segmentfault.com/a/11...