[英]Positioning section and aside
Heyo,因此在缩小屏幕时,我在拨出部分和正确定位方面有些困难。 当收缩屏幕时,该部分会掉到一边。 这是笔: https : //codepen.io/anon/pen/gxjbyg
这是代码:
#container {
width:90%;
margin: 0 auto;
background:pink;
height:300px;
}
aside {
width:12%;
height:100px;
background:green;
border-radius:20px;
display:inline-block;
margin-right:20px;
}
section {
width:86%;
height:100px;
background:purple;
border-radius:20px;
display:inline-block;
}
使用width:calc(86% - 20px);
一是考虑您在aside
使用margin-right
为20px;
#container { width:90%; margin: 0 auto; background:pink; height:300px; } aside { width:12%; height:100px; background:green; border-radius:20px; display:inline-block; margin-right:20px; } section { width:calc(86% - 20px); height:100px; background:purple; border-radius:20px; display:inline-block; }
<div id="container"> <aside>ASIDE</aside> <section>SECTION</section> </div>
在这里margin-right: 20px;
顺便说一句,导致整体宽度增加到100%以上。 减少到margin-right: 15px;
这将解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.