How to change the reference point of a inline-block element

Here is my code for trees:

/* Tree */

.tree ul {
  padding-top: 20px;
  position: relative;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}

.tree li {
  display: table-cell;
  text-align: center;
  list-style-type: none;
  position: relative;
  /*the padding is 20px + border-top = 23px*/
  padding: 23px 5px 0 5px;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}


/*We will use ::before and ::after to draw the connectors*/

.tree li::before,
.tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 3px solid #ccc;
  width: 50%;
  height: 20px;
}

.tree li::after {
  right: auto;
  left: 50%;
  border-left: 3px solid #ccc;
}


/*We need to remove left-right connectors from elements without 
any siblings*/

.tree li:only-child::after,
.tree li:only-child::before {
  display: none;
}


/*Remove space from the top of single children*/

.tree li:only-child {
  padding-top: 0;
}


/*Remove left connector from first child and 
right connector from last child*/

.tree li:first-child::before,
.tree li:last-child::after {
  border: 0 none;
}


/*Adding back the vertical connector to the last nodes*/

.tree li:last-child::before {
  border-right: 3px solid #ccc;
  border-radius: 0 5px 0 0;
  -webkit-border-radius: 0 5px 0 0;
  -moz-border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
  border-radius: 5px 0 0 0;
  -webkit-border-radius: 5px 0 0 0;
  -moz-border-radius: 5px 0 0 0;
}


/*Time to add downward connectors from parents*/

.tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 3px solid #ccc;
  width: 0;
  height: 20px;
}

.tree li .family {
  position: relative;
}


/* Person */

.person {
  border: 3px solid black;
  padding: 10px;
  min-width: 150px;
  #min-height: 100px;
  to increase the min height of the boxes background-color: #FFFFFF;
  display: inline-block;
}

.person.female {
  border-color: #F45B69;
  top: 0px
}

.person.male {
  top: 0px;
  border-color: #456990;
}

.person .content {
  font-size: 16px;
  align=center;
  text-align: center;
}
<body bgcolor="white" background="" vlink="peru" alink="peru" link="peru">
  <p align=center>
    <br><br>
    <b>
      <font size=6> <I> FAMILY TREE </I> </font>
      </br>

      <div class="tree" align=center>
        <ul>
          <li>
            <div class="person child male">
              <div class="content">
                Dupont Charles </br>
                France, 1900 - France, 1970</br></br>
                <div align=left>
                  Spouse: Celine, born Dupone</br>
                  &#10551 TREE
                </div>
              </div>
            </div>
            <ul>
              <li>
                <div class="person child male">
                  <div class="content">Uncle</br></br></div>
                </div>
              </li>
              <li>
                <div class="person child female">
                  <div class="content">Aunt blabla</br>blabla</br>blabla</div>
                </div>
              </li>
              <li>
                <div class="person child female">
                  <div class="content">Mother</br>&nbsp</div>
                </div>
                <ul>
                  <li>
                    <div class="person child male">
                      <div class="content">Me</div>
                    </div>
                  </li>
                  <li>
                    <div class="person child female">
                      <div class="content">Sister</div>
                    </div>
                    <ul>
                      <li>
                        <div class="person child male">
                          <div class="content">Me</div>
                        </div>
                      </li>
                      <li>
                        <div class="person child female">
                          <div class="content">Sister</div>
                        </div>
                      </li>
                    </ul>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </div>
  </p>
</body>

This works well, but my problem is that when the box is higher than normal, the vertical rules do not extend to the other boxes on the same line.
The problem seems to be that the reference point of a inline-box is always at the bottom left of the box, while I would need it to be at the top left corner (see the blabla box in picture below). What could be done?
problem_tree_html

>Solution :

Because you’re using display: table-cell you can use vertical-align: top to move the child divs to the top of the cell.

There’s a whole load of deprecated html you’re using like <font> that you probably want to look at. I’ve also changed align=center to align:center in the last rule in your CSS though I’ve not looked at what effect it has.

Marked up code below

/* Tree */

.tree ul {
  padding-top: 20px;
  position: relative;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}

.tree li {
  display: table-cell;
  text-align: center;
  vertical-align: top; /* added this */
  list-style-type: none;
  position: relative;
  /*the padding is 20px + border-top = 23px*/
  padding: 23px 5px 0 5px;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}


/*We will use ::before and ::after to draw the connectors*/

.tree li::before,
.tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 3px solid #ccc;
  width: 50%;
  height: 20px;
}

.tree li::after {
  right: auto;
  left: 50%;
  border-left: 3px solid #ccc;
}


/*We need to remove left-right connectors from elements without 
any siblings*/

.tree li:only-child::after,
.tree li:only-child::before {
  display: none;
}


/*Remove space from the top of single children*/

.tree li:only-child {
  padding-top: 0;
}


/*Remove left connector from first child and 
right connector from last child*/

.tree li:first-child::before,
.tree li:last-child::after {
  border: 0 none;
}


/*Adding back the vertical connector to the last nodes*/

.tree li:last-child::before {
  border-right: 3px solid #ccc;
  border-radius: 0 5px 0 0;
  -webkit-border-radius: 0 5px 0 0;
  -moz-border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
  border-radius: 5px 0 0 0;
  -webkit-border-radius: 5px 0 0 0;
  -moz-border-radius: 5px 0 0 0;
}


/*Time to add downward connectors from parents*/

.tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 3px solid #ccc;
  width: 0;
  height: 20px;
}

.tree li .family {
  position: relative;
}


/* Person */

.person {
  border: 3px solid black;
  padding: 10px;
  min-width: 150px;
  #min-height: 100px;
  to increase the min height of the boxes background-color: #FFFFFF;
  display: inline-block;
}

.person.female {
  border-color: #F45B69;
  top: 0px
}

.person.male {
  top: 0px;
  border-color: #456990;
}

.person .content {
  font-size: 16px;
  align:center; /* changed this from  = to : */
  text-align: center;
}
<body bgcolor="white" background="" vlink="peru" alink="peru" link="peru">
  <p align=center>
    <br><br>
    <b>
      <font size=6> <I> FAMILY TREE </I> </font>
      </br>

      <div class="tree" align=center>
        <ul>
          <li>
            <div class="person child male">
              <div class="content">
                Dupont Charles </br>
                France, 1900 - France, 1970</br></br>
                <div align=left>
                  Spouse: Celine, born Dupone</br>
                  &#10551 TREE
                </div>
              </div>
            </div>
            <ul>
              <li>
                <div class="person child male">
                  <div class="content">Uncle</br></br></div>
                </div>
              </li>
              <li>
                <div class="person child female">
                  <div class="content">Aunt blabla</br>blabla</br>blabla</div>
                </div>
              </li>
              <li>
                <div class="person child female">
                  <div class="content">Mother</br>&nbsp</div>
                </div>
                <ul>
                  <li>
                    <div class="person child male">
                      <div class="content">Me</div>
                    </div>
                  </li>
                  <li>
                    <div class="person child female">
                      <div class="content">Sister</div>
                    </div>
                    <ul>
                      <li>
                        <div class="person child male">
                          <div class="content">Me</div>
                        </div>
                      </li>
                      <li>
                        <div class="person child female">
                          <div class="content">Sister</div>
                        </div>
                      </li>
                    </ul>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </div>
  </p>
</body>

Leave a Reply