I want to draw a circle on the intersections of html tables, but I am not sure how to get shapes into html tables. I want it to look like something just like picture below. I tried to use text and span, such as using border-radius to get the circle shape but I can’t seem to figure out how to make it appear on the intersections.
2
Answers
You could use the ::after pseudo-element like this:
This code will give you a small red circle on the bottom-right corner of every table cell. Starting with that, you can be more specific with what cell to add that circle using classes or pseudo-classes.
EDIT:
Added other examples using pseudo-classes.
Also, to explain what’s happening:
What does the trick is the
position: relative
in thetd
and theposition: absolute
in the::after
pseudo-element.This allows us to position the pseudo-element relative to its parent, the table cell. Meaning, if we use
right: 0
, our circle will be positioned starting on the right side of the table cell.So, we set
right
andbottom
to the negative half of the width/height of the circle (the radius) so its center point is positioned on the intersection.Finally, border-radius gives us the round shape we want.
You can create pseudo element to draw circle and position it within the table.