Search code examples
htmlcssblock

How to display elements in block


I want the elements below to line up under each other. As you can see in the picture the gray element is not lining up like the others.


Solution

  • If what you would like is to replicate the code, you could do it like this:

    #holder {
      width: 300px;
      height: 300px;
      border: 1px solid black;
    }
    
    #gray {
      width: 100%;
      height: 33.333%;
      background-color: gray;
    }
    
    #red {
      width: 100%;
      height: 33.333%;
      background-color: red;
    }
    
    #orange {
      width: 100%;
      height: 33.333%;
      background-color: orange;
    }
    <div id="holder">
      <div id="red">
      </div>
      <div id="gray">
      </div>
      <div id="orange">
      </div>
    </div>

    If you have current code though that you would like fixed, please post it here :)