gpt4 book ai didi

html - 左右边距不相等,这是为什么

转载 作者:太空宇宙 更新时间:2023-11-04 16:06:16 25 4
gpt4 key购买 nike

只是练习 div 定位。在下面的代码中,RED 和 GREEN div 位于 .content div 中。左边距(红色 div 的左侧)和右边距(绿色 div 的右侧)均设置为 0.3%

正因为如此,左右两侧暴露出两条深蓝色垂直小条(实际上是 .content div 的颜色)。但是,如果您注意到,线宽并不相等。请查看屏幕截图以更好地理解这一点。为什么即使在两者上都设置了相等的边距之后仍然如此?

Screenshot

html,body {
margin: 0px;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
background-color: rgba(173,192,241,1);
}

.wrapper {
height: 725px;
max-width: 960px;
margin-left: auto;
left: 0px;
top: 0px;
/* [disabled]background-color: rgba(15,26,155,1); */
margin-right: auto;
position: relative;
}



.topimage {
width: 100%;
max-width: 960px;
height: 100%;
max-height: 175px;
/* [disabled]background-color: rgba(0,102,204,1); */
position: absolute;
/* [disabled]border: thin solid rgba(255,0,0,1); */
}

.topimage img{
max-width: 100%;
max-height: 100%;
/* [disabled]margin-bottom: -9px; */
display: block;
margin-right: auto;
margin-left: auto;
border-radius: 15px 15px 0px 0px;
}

.menu {
background-color: rgba(15,26,155,1);
height: 100%;
max-height: 50px;
max-width: 960px;
position: relative;
top: 20px;
}

.content {
width: 100%;
height: 500px;
background-color: rgba(20,35,214,1);
position: relative;
top: 20px;
}

.leftcontent {
background-color: rgba(255,0,0,1);
float: left;
height: 100%;
max-height: 500px;
width: 100%;
max-width: 83.7%;
top: 175px;
/* [disabled]position: relative; */
border-left-color: rgba(205,205,205,1);
margin-left: 0.3%;
}

.rightcontent {
background-color: rgba(0,255,0,1);
float: right;
height: 100%;
max-height: 500px;
width: 100%;
max-width: 15.7%;
/* [disabled]position: relative; */
top: 175px;
margin-right: 0.3%;
}

.footer {

}
<div class="wrapper">
<div class="topimage">

</div>
<div class="menu">
</div>

<div class="content">
<div class="leftcontent">
</div>
<div class="rightcontent">
</div>
</div>

</div>

最佳答案

它占 .3% 的 rightcontent div你的 leftcontent div 和 rightcontent div 不等于 Margin 不等于

关于html - 左右边距不相等,这是为什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37916071/

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