html - How to vertically align text in a definition list? -
i have definition list. want vertically align text in middle of each dd.
dl, dt, dd { margin:0; } dt { background: blue; } dd { min-height: 100px; background: gold; border-bottom: 3px solid white; }
<dl> <dt>fruit</dt> <dd>apple</dd> <dd>banana</dd> <dd>pear</dd> </dl>
i've tried using table cell method - jsfiddle. has caused of dd's output in 1 line when should on top of each other.
how can stacked list, text vertically aligned in each gold coloured section?
please note: no flexfox please, , text multi-lined.
since can add tags <dd>
, here solution, set each <dd>
table
, each <span>
inside table-cell
, can set vertical alignment it.
it works multiple lines of text, see following demo.
dl, dt, dd { margin:0; } dl { width: 100px; } dt { background: crimson; } dd { display: table; border-collapse: collapse; width: 100%; height: 100px; background: gold; } dd span { display: table-cell; vertical-align: middle; border: 1px solid white; }
<dl> <dt>fruit</dt> <dd><span>apple</span></dd> <dd><span>banana, love bananas.</span></dd> <dd><span>pear</span></dd> </dl>
Comments
Post a Comment