html - Display: table-cell, contents and padding -
i have straightforward html page displays content in 2 columns. format columns i'm using <div>
outer container (display: table-row) , 2 inner <div>
actual columns (display: table-cell). 1 of these columns has padding @ top. markup looks following - markup , styles omitted clarity:
<style> .row { display: table-row } .cell { display: table-cell; border: 1px solid black; width: 150px } .content { background-color: yellow } </style> <div class="row"> <div class="cell"> <div class="content">some content; not padded.</div> </div> <div class="cell"> <div class="content">more content; padded @ top.</div> </div> </div>
i'm getting this:
but expected this:
the behavior same whether padding-top
applied cell or content. missing anything? thanks.
you can achieve 2 desired results using padding
, margin
on div class content
. remember, padding contribute overall width , height of object, extend background color.
first screen shot:
<div class="content" style="margin-top: 10px">more content; padded @ top.</div>
second screen shot:
<div class="content" style="padding-top: 10px">more content; padded @ top.</div>
Comments
Post a Comment