javascript - CSS 气泡云
问题描述
我正在尝试生成类似于此的气泡云/气泡图,但没有动画: https ://codepen.io/seogi1004/pen/WaWZOz
气泡应该居中而不重叠,以尽量减少它们之间的空间。
这是我目前的进展: https ://codepen.io/FelixRe/pen/PobjNyM
#css
.circle{
border-radius: 50px;
border: 1px solid black;
margin: 1px;
display: flex;
justify-content: center;
align-items: center;
}
.container{
display: flex;
flex-wrap: wrap;
width: 500px;
}
#app{
display: flex;
justify-content: center;
}
.active{
background-color: red;
}
#html
<div id="app">
<div class="container">
<span
v-for="i in 20"
:key="i"
:style="size()"
class="circle"
>
<span class="body-1">{{ i }}</span>
</span>
</div>
</div>
#script
const app = Vue.createApp({
methods: {
random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
},
size() {
const size = this.random(80, 100)
return 'width: ' + size + 'px; height: ' + size + 'px;'
},
},
})
app.mount('#app')
您认为没有硬编码绝对位置的精益方式吗?
解决方案
推荐阅读
- sql - 检查工作日而不是周末的日子
- gitlab - 如何从 Airflow 实例化(运行)存储在私有 Gitlab 容器注册表中的容器?(来自托管气流服务?)
- php - 在 SMARTY 中重建嵌套数组
- python - 来自 sklearn 的 MLPclassifier 在其他机器上执行时显示不同的精度?
- android - 如何获取滑行的自行车图片网址?
- reactjs - React Router onEnter 与 Redux 身份验证
- bootstrap-5 - 如何在 bootstrap 版本 5 中导入 bootstrap-select?
- r - 在社交网络分析中查找间接节点(在 R 中,*使用 dplyr*)
- terraform - 获取状态锁时出错:资源暂时不可用
- sql - 如何在使用 postgreSQL 接收条件值的表中创建一个新列?