码迷,mamicode.com
首页 > 其他好文 > 详细

border占居了宽度,导致子元素在父元素中换行问题解决

时间:2019-10-05 16:18:56      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:code   order   问题解决   ali   point   item   height   解决   center   

方法一:将border改成outline

outline是不占据父级空间的

.chess {
    width : 50px;
    height: 50px;
    outline: 2px solid lightgray;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

方法二: 将盒子设置成border-box

.chess {
    width : 50px;
    height: 50px;
    border: 2px solid lightgray;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

border占居了宽度,导致子元素在父元素中换行问题解决

标签:code   order   问题解决   ali   point   item   height   解决   center   

原文地址:https://www.cnblogs.com/zhizhi0810/p/11624692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!