I have a <ul>
-list, where each list item contains multiple sections of text.
I want want each section of text to be as narrow as possible, but I still want all of them to be aligned vertically across the items. E.g.
<ul>
<li> A. Name | Some complex address | 555-1234 </li>
<li> Longer Name | Short Addr. | 555-1234 </li>
<li> P. Diddy | No home | 555-1234 </li>
</ul>
I hoped css grid would solve this issue for me, but I can't figure it out...
ul {
list-style: none;
display: grid;
justify-content: stretch;
}
li {
display: grid;
grid-template-columns: auto 1fr auto;
grid-column-gap: 10px;
}
p:nth-child(1) {
background: #EEEEEE;
border-right: 1px solid;
}
p:nth-child(2) {
background: #CECECE;
border-right: 1px solid;
}
p:nth-child(3) {
background: #EEEEEE;
}
<ul>
<li>
<p>A. Name</p>
<p>Some complex address</p>
<p>555-1234</p>
</li>
<li>
<p>Longer Name</p>
<p>Short Addr.</p>
<p>555-1234</p>
</li>
<li>
<p>P. Diddy</p>
<p>No home</p>
<p>555-1234</p>
</li>
</ul>
Is css grid the wrong tool for the job, or am I missing something here?