JSFiddle - React, Tailwind, and code Playground
by Vallek
HTML
<div class="container1">
<token>Effects</token>
<token>of</token>
<token>an</token>
<token>ascorbic</token>
<elem type="drug">
<token>acid-derivative</token>
<token>dentifrice</token>
<div class=" label drug">
Drug
</div>
</elem>
<token>in</token>
<elem type="person">
<token>patients</token>
<div class=" label person">
Person
</div>
</elem>
<token>with</token>
<elem type="disease">
<token>gingivitis</token>
<div class=" label disease">
Disease
</div>
</elem>
</div>
CSS
.container1 {
display: inline-block;
margin-top: 50px;
border: 1px solid #aaa;
padding: 3px 8px 0 0;
}
token {
margin-left: 6px;
}
elem[type="drug"],
elem[type="person"],
elem[type="disease"] {
position: relative;
}
elem[type="drug"]::after,
elem[type="person"]::after,
elem[type="disease"]::after {
content: "";
position: absolute;
top: -1em;
left: 3%;
width: 94%;
height: 0.5em;
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #aaa;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
z-index: 10;
}
.label {
position: absolute;
top: -3em;
left: 3%;
width: 94%;
z-index: 10;
text-align: center;
}
.label:after {
content: "|";
position: absolute;
top: 1.2em;
left: 3%;
width: 94%;
z-index: 10;
text-align: center;
color: #aaa;
}
.drug {
color: red;
}
.person {
color: blue;
}
.disease {
color: green;
}