I am trying to create a span
element positioned as absolute
inside a div
. The div
has top
and left
values set. When the user inputs text, the span expands with the given text towards the right to contain it. However, I would like it to grow symmetrically on both sides. For example, if the user inputs a word of 7 characters, the character in position #4 should be exactly centered.
Is there a way to achieve this using pure CSS? Alternatively, is there a method to adjust the value of left
using JavaScript with good accuracy?