Can I set up tab stops in html5?

后端 未结 6 1571
北海茫月
北海茫月 2021-02-13 03:10

I would like to set up tab stops in html5 and be able to align text to them, just like in Word. For my application I can\'t use tables. Is there a way to do this? Do I have t

6条回答
  •  悲&欢浪女
    2021-02-13 03:44

    I know the question said no tables, and the previous JS answer was unpopular, but someone should find this useful. It doesn't do true tab stops, but that's not possible even with CSS.

    If you don't want to do a bunch of manual span or table tags, this JS automatically turns all elements of class "tabs" into a table when the page loads, using tab characters as a guide.

    JS Fiddle: https://jsfiddle.net/s7m6zggp/7/

    Edit: On second thought, maybe not the best approach. The regex is throwing my brain for a loop. But I'll keep the Fiddle up in case anyone wants to use it.

提交回复
热议问题