如何设置子div两个div 50%,50%与父div [英] how to set the child two div 50%, 50% with the parent div

查看:166
本文介绍了如何设置子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%;
}

示例



重要注意事项:



<
  • 不要在div之间留下空格

  • 您也可以使用浮动而不是 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%;
    }
    

    Example

    Important notes:

    1. don't leave whitespaces between the divs
    2. You might as well use floats instead of display:inline-block;
    3. 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆