gpt4 book ai didi

html - CSS Float Clear Both 50% width Div with Border

转载 作者:行者123 更新时间:2023-11-28 16:11:29 25 4
gpt4 key购买 nike

HTML

<div>
<div class="leftInRow5050 squareTopLeft">1</div>
<div class="rightInRow5050 squareTopRight">2</div>
<div style="clear: both;"></div>
</div>
<div>
<div class="leftInRow5050 squareBottomLeft">3</div>
<div class="rightInRow5050 squareBottomRight">4</div>
<div style="clear: both;"></div>
</div>

CSS

.rightInRow5050{
width:50%;
display: inline-block;
float:right;
}

.leftInRow5050{
width:50%;
display: inline-block;
float:left;
}
.leftInRow5050.squareTopLeft{
height: 35%;
border-right: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
}

.rightInRow5050.squareTopRight{
height: 35%;
border-left: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
}

.leftInRow5050.squareBottomLeft{
height: 35%;
border-right: 1px solid #CCCCCC;
border-top: 1px solid #CCCCCC;
}

.rightInRow5050.squareBottomRight{
height: 35%;
border-left: 1px solid #CCCCCC;
border-top: 1px solid #CCCCCC;
}

为什么上面的代码无法创建 2X2 <div>矩阵?它给了我标准的 1px 问题,其中 <div>是彼此相克吗?

最佳答案

如果 div 有边框,而这就是它的问题,试试这个:

box-sizing:border-box;

关于html - CSS Float Clear Both 50% width Div with Border,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22349875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com