如何设置子div两个div 50%,50%与父div [英] how to set the child two div 50%, 50% with the parent div
本文介绍了如何设置子div两个div 50%,50%与父div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下种类的模式。如何将第一个和第二个childDiv类的css更改应用到父div的50%
如何设置50%,50%到子div? p>
< div class =parentDiv>
< div class =childDiv> // 50%width
< / div>
< div class =childDiv> // 50%width
< / div>
< / div>
解决方案
.childDiv {
display:inline-block;
width:50%;
}
重要注意事项:
<
display:inline-block;
box-sizing
,只是省略边界(仅用于说明目的)。
I have following kind of pattern. How to apply a css changes for first and second childDiv class to 50% to the parent div
How do I set 50%, 50% to the child div?
<div class="parentDiv">
<div class="childDiv"> // 50% width
</div>
<div class="childDiv"> // 50% width
</div>
</div>
解决方案
.childDiv{
display:inline-block;
width:50%;
}
Important notes:
- don't leave whitespaces between the divs
- You might as well use floats instead of
display:inline-block;
- If the elements don't align in the example, you browser does not support
box-sizing
, just omit the border then (it was for illustration purposes only).
这篇关于如何设置子div两个div 50%,50%与父div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文