3 回答

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊
嘗試這樣的系統(tǒng):
HTML:
<section class="container">
<div class="one"></div>
<div class="two"></div>
</section>
CSS:
.container {
width: 80%;
height: 200px;
background: aqua;
margin: auto;
padding: 10px;
}
.one {
width: 15%;
height: 200px;
background: red;
float: left;
}
.two {
margin-left: 15%;
height: 200px;
background: black;
}
如果您在另一個(gè)div上使用margin-left等于第一個(gè)div的寬度,則只需浮動(dòng)一個(gè)div。無(wú)論變焦如何,這都將起作用,并且不會(huì)出現(xiàn)子像素問題。

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊
使用flexbox很容易:
#wrapper {
display: flex;
}
#left {
flex: 0 0 65%;
}
#right {
flex: 1;
}
<div id="wrapper">
<div id="left">Left side div</div>
<div id="right">Right side div</div>
</div>
添加回答
舉報(bào)