如图的flex骰子布局是怎么实现的?

clipboard.png
看了阮一峰大神的博客是如下写的,可是怎么都没有效果

<div class="box">
  <span class="item"></span>
  <span class="item"></span>
</div>


.box {
  display: flex;
}

.item:nth-child(2) {
  align-self: center;
}

只能是如下的效果

clipboard.png

阅读 5.8k
3 个回答

他的这个例子没写对,他页面上还有其他一些例子是错的

可以再增加第三个 item ,背景设为透明来隐藏
然后 box 设置 justify-content: space-between

body{
    background: rgb(44, 44, 44)
}    
.box {
    display: flex;
    width: 200px;
    height: 200px;
    background: rgb(225,225,225);
    border-radius:10px;      
    border:outset white 10px;
}
.item{        
    width: 30%;
    height: 30%;          
    background: rgb(44, 44, 44);
    border-radius: 50%;
}
        

.item:nth-child(1) { 
    margin: 5px 
 } 
.item:nth-child(2) {
    align-self: center;
}

样式没加,哥们

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进