I’m trying to achieve vertical lines similar to this:
I have the following content structure as starting point inside a div…
Do note there are lots of headings and paragraphs and the line has to support at least five concurrent lines.
adding borders to each p element, problem is how can I set five borders…
convert them to a unordered list, which should make it easier to create lines, but it may collide with unordered lists inside the div that contains the content and may cause unexpected layout changes.
There are many ways to accomplish the look, but I find seeing what others have done helps a lot. For example, VSCode in the browser has the following structure:
I removed a lot of attributes, and elements 2-17, but you can see how each element keeps track of its “index” (position), this way, you can indent the item the correct amount.
Thank you!!
It definitively helps. Some question, if I pretend to insert with vanilla JS a div with position absolute before each content element, which would contain the divs with class
“indent-guide” and calculate the level of nesting based on previous heading tag (which I already do so that code would be ready) and insert according to that the number of divs with class “indent-guide” , what would you advice? and would it be too much of a performance problem to do so?
What I’m struggilng is how to detect that after a title it comes a paragraph, before it was simple just to check the nodename of next/previous elements, but with the divs the strucutre is dfferent… so far I have tried current[counter].parentNode.nextElementSibling.childNodes[0].nodeName ; where “current” is the heading but I’m getting error that is null