I encounter this issue frequently, where my usual methods for centering objects do not seem to work. I am in search of a universal way to accomplish this task:
<div>
<span>content</span>
<span> content</span>
<span>content </span>
<span> content </span>
<span>content</span>
<span>content</span>
</div>
My attempts at using
margin-left:auto; margin-right:auto;
have been unsuccessful. I also experimented with margin-left:Xpx;
. In a previous project, I found success with display:inline-block
and display:table-cell
, but these approaches are not consistent. I applied these solutions to both the divs and spans.
Moreover, I am struggling to style margin-top
and margin-bottom
for this particular scenario.
In summary, I aim to centrally align the div while adding margins to the spans. I would appreciate guidance on what I may be overlooking conceptually. Thank you.