父div设置宽度100子div设置50宽度如何设置使子div靠左显示
要使子div靠左显示,可以给父div设置display: flex;属性,并使用justify-content: flex-start;属性来对齐子div。以下是一个示例代码:
HTML代码:
<div class="parent">
<div class="child">
子div内容
</div>
</div>
CSS代码:
.parent {
width: 100%;
display: flex;
justify-content: flex-start;
}
.child {
width: 50%;
}
这样子div将会占据父div的50%宽度,并且靠左显示。
原文地址: http://www.cveoy.top/t/topic/iJMQ 著作权归作者所有。请勿转载和采集!