JSFiddle - React, Tailwind, and code Playground
HTML
<div class = "spotlight">
<div class = "container spotlight__main">
<h2><span class ="background__red">In the spotlight</span> </h2>
</div>
</div>
CSS
.background__red{
background-color: red;
padding: 8px 35px;
margin-left: 2rem;
color: white;
}
.spotlight{
background-color: lightgrey;
}
.spotlight__main {
border: 1px solid black;
}
.container {
max-width: 960px;
margin: 0 auto;
vertical-align: center;
}
h2 > span {
position: relative;
display: inline-block;
}
h2 > span:before,
h2 > span:after {
content: "";
position: absolute;
top: 50%;
border-bottom: 1px dashed;
width: 96rem;
margin: 0 auto;
vertical-align: center;
}
h2 > span:before {
right: 100%;
}
h2 > span:after {
left: 100%;
}