I am attempting to use CSS to recreate something similar to formatting of comment boxes in Word, where the comment box will be wherever you insert the anchor for the comment to be, but if there are more comments than room permits, it shuffles the comment boxes accordingly, while keeping it anchored somewhat close to the anchor if possible. The comment box text should also not impact the main document's formatting at any time.
I attempted implementation where I have position: absolute; comment boxes on the side of a large paragraph of text, let's just say, it's a <p> or anything else, I don't think that really matters... And you basically have something like:
<p>
lalalal lalala lal lalalalal
just assume that the lines collapse as needed
but in reality, this will be one big paragraph
yes, we'll keep going for the sake of this exercise
yay
okay, quasi anchor point here ****
<div class='commentBox'>
I am the first comment bboooxxxx
let's get a few lines baby
I am lovin it!
Just do it
</div>
keep going
yes we are still going
<div class='commentBox'>
I am gonna cover you up, first box
</div>
okay, let's call it done
</p>
Where the simplistic form of css for commentBox will be:
.commentBox {
position: absolute;
left: 400 px; /*Whatever more than the width of the settings for the <p> tag*/
border: solid lightpink;
}
While this works fine for one comment, multiple comments will inevitably overlap. So, there are a couple ways we can deal with it. First will be table everything right? We can force rows at places where comments get added, and that will just create more row displays for each comment that gets added. But that's a terribly not-elegant solution. It breaks the text, and makes keeping track of everything hard.
I thought about using two columns too, then adding stuff to them separately with position: relative. But I couldn't quite figure out how to make sure that the comments get anchored properly at a certain position within the paragraph of text for that approach. It will just ended up being mashed together - it won't overlap, but that's functionally unacceptable.
So I started looking around SO and not running into much luck. It appears that most approaches involve changing it to position: relative, which I really do not have an issue with but I couldn't quite figure out if I do change it to relative, how I can make sure that the main paragraph's formatting does not get impacted as a result.
Anybody have done something similar before? How did you do it? Or if you haven't, how would you do it?