html - Inline block with dynamic height not aligned to the top -


i have 2 inline-block elements sitting side-by-side acting columns. first column changes height because add contents it.

my problem second column follows bottom of expanding first column since both inline-block. want second column stick top , not follow bottom of other element.

jsfiddle

$("a").click(function(e) {    e.preventdefault();    $("<p>lorem ipsum...</p>").appendto($("#dynamic"));  });
.col {    display: inline-block;    width: 20%;    margin: 0;    background-color: #dadada;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <div class="col" id="dynamic">    <p>lorem ipsum...</p>  </div>  <div class="col">    <p><a href="#">click me</a></p>  </div>

the default value vertical-align baseline, change top.

$("a").click(function(e) {    e.preventdefault();    $("<p>lorem ipsum...</p>").appendto($("#dynamic"));  });
.col {    display: inline-block;    width: 20%;    margin: 0;    background-color: #dadada;    vertical-align: top; /*added*/  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <div class="col" id="dynamic">    <p>lorem ipsum...</p>  </div>  <div class="col">    <p><a href="#">click me</a>    </p>  </div>


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -