我試圖放置寬度各爲50%的兩個div,但某種程度上它不在同一行上顯示,但如果我做了49%,它會堆疊在同一行中。任何人都可以告訴我我在做什麼錯了代碼(更感興趣知道原因比解決方案)。內聯兩個div並排 - CSS
CSS -
* {
padding: 0;
margin: 0;
}
.wrapper {
width: 100%;
}
.left-c {
width: 50%;
background: #3EF00C;
display: inline-block;
}
.right-c {
width: 50%;
background: #2E4E6E;
display: inline-block;
}
HTML -
<div class="wrapper">
<div class="left-c">
<p>LEFT ----- This is going to be some random text placed in a a left container inside the wrapper. I hope this text will suffice the requirement.</p>
</div>
<div class="right-c">
<p>This is going to be some random text placed in a a right container inside the wrapper. I hope this text will suffice the requirement. ----- RIGHT</p>
</div>
</div>
JS小提琴 - https://jsfiddle.net/no0chhty/1/
https://jsfiddle.net/no0chhty/4/ – mika