CSS Layout How to - Float left with 30 percent width parent, 100 percent children








Question

We would like to know how to float left with 30 percent width parent, 100 percent children.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#wrapper {<!--from  w  w  w.j  a  v a  2  s .c o  m-->
  width: 100%;
}

#div1, #div3 {
  float: left;
  width: 30%;
}

#div2 {
  float: left;
  width: 40%;
}


#Button1, #Button2, #Button3 {
  width: 100%
}
</style>
</head>
<body>
  <div id="wrapper">
    <div id="div1">
      <div id="subdiv1">
        <button id="Button1">Button 1</button>
      </div>
    </div>
    <div id="div2">
      <div id="subdiv2">
        <button id="Button2">Button 2</button>
      </div>
    </div>
    <div id="div3">
      <div id="subdiv3">
        <button id="Button3">Button 3</button>
      </div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: