One alternative (cross-browser) approach is to give relative positioning of the list of parent definitions:
dl {position: relative;}
and then give each subelement an absolute position in the definition list.
dt, dd {display: block; position: absolute;}
(Naturally, since we are now using absolute positioning, this will only be a viable alternative if you have a good idea of ββwhat maximum width of each data column and maximum height of each data row should be).
In this case, you still have to specify an explicit left value for each dt and dd , but the declaration is identical every time, except for the index (referenced three times), which increases so much ..
Example:
Index 2: dt:nth-of-type(2), dt:nth-of-type(2) ~ dd {left: calc((1px + 1em + 200px + 1em + 1px) * (2 - 1));} Index 3: dt:nth-of-type(3), dt:nth-of-type(3) ~ dd {left: calc((1px + 1em + 200px + 1em + 1px) * (3 - 1));} Index 4: dt:nth-of-type(4), dt:nth-of-type(4) ~ dd {left: calc((1px + 1em + 200px + 1em + 1px) * (4 - 1));}
and etc.
Working example:
dl { position: relative; } dt { text-align: center; font-weight: bold; } dt, dd { display: block; position: absolute; width: 200px; height: 50px; min-height: 50px; margin-left: 0; border: 1px solid lightgray; padding: 0 1em; vertical-align: top; } dt { top: 0; } dd:nth-of-type(3n - 2) { top: 50px; height: 200px; color: rgb(244, 67, 54); } dd:nth-of-type(3n - 1){ top: 250px; color: rgb(255, 152, 0); } dd:nth-of-type(3n) { top: 300px; color: rgb(76, 175, 80); } dt:nth-of-type(2), dt:nth-of-type(2) ~ dd { left: calc((1px + 1em + 200px + 1em + 1px) * (2 - 1)); } dt:nth-of-type(3), dt:nth-of-type(3) ~ dd { left: calc((1px + 1em + 200px + 1em + 1px) * (3 - 1)); }
<dl> <dt><p>Term 1</p></dt> <dd> <p>Definition of term 1 long long long long</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> </dd> <dd><p>Definition of term 1</p></dd> <dd><p>Definition of term 1</p></dd> <dt><p>Term 2</p></dt> <dd><p>Definition of term 2</p></dd> <dd><p>Definition of term 2</p></dd> <dd><p>Definition of term 2</p></dd> <dt><p>Term 3</p></dt> <dd><p>Definition of term 3</p></dd> <dd><p>Definition of term 3</p></dd> <dd><p>Definition of term 3</p></dd> </dl>
source share