I am working with a wrapper/list structure using ul
and li
elements. The ul
element is set to display: table-row;
, while the li
element is set to display: table-cell;
. I am facing an issue where I need to center the li
element within the list, but align the text inside the li
element to the left.
Here is the current code snippet:
.list-wrapper {
display: table;
margin: 0;
position: relative;
table-layout: fixed;
width: 100%;
}
.list {
display: table-row;
width: 100%;
}
.list-item {
display: table-cell;
text-align: center;
}
.item-link {
text-align: left;
}
<div class="list-wrapper">
<ul class="list">
<li class="list-item">
<a class="item-link">
Text over more lines. Align me left but my parent centered.
</a>
</li>
<li class="list-item">
<a class="item-link">
Also centered.
</a>
</li>
<li class="list-item">
<a class="item-link">
Here is some text. Align me left.
</a>
</li>
<li class="list-item">
<a class="item-link">
Text.
</a>
</li>
</ul>
</div>
Any suggestions on how to address this challenge?