Align Div Horizontally and Responsive in HTML5

Let’s start with the HTML code:
  1. <div class="main">
  2. <div class="first"> First Div </div>
  3. <div class="second"> Second Div </div>
  4. <div class="third"> Third Div </div>
  5. <div class="clear"></div>
  6. </div>
Here I’ve three Div’s and now I am going to apply a style to it.
  1. main {
  2. width: 100 %;
  3. }
  4. .first {
  5. width: 30 %;
  6. height: 100 px;
  7. background: #CCC;
  8. float: left;
  9. }
  10. .second {
  11. width: 30 %;
  12. height: 100 px;
  13. background: green;
  14. float: left;
  15. }
  16. .third {
  17. width: 30 %;
  18. height: 100 px;
  19. background: red;
  20. float: left;
  21. }
  22. .clear {
  23. clear: both;
  24. }
I’ve set the width of main Div as 100% - full width. And the width of the three div’s are also set in percentage. This property is used to make the design responsive.
The output will be the following:
output
Here you can find the fiddle. : https://jsfiddle.net/saranyatr/12tsq8bd/.