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.
$("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
Post a Comment