I need to create text that contains a white background, where this background needs to have a centered height to the text, as in the image below:
This is my code:
body, html{
background:black;
}
.text-format {
width: 280px;
background-color: white;
padding-left: 40px;
}
.text-format span {
font-family: 'SimplonBP Bold', Courier, monospace;
font-size: 70px;
color: #00d318;
}
<div class="text-format"><span>Stacqé</span></div>
How can I make this possible?
4
Answers
Could you use a black border and set a height on the
text-format
div, then position the span inside it?You may decrease line-height and use gradient and background-clip to draw the background-colors:
example:
You could create a pseudo element (
::after
or::before
) for the background, combine relative/absolute positions on the different elements and apply accordingz-index
values as demonstrated below.Additionally, if you move the
font-size
property to the rule of the parent element (.text-format
), you can useem
values for theheight
andtop
parameters of the pseudo element, which makes these values relative to the font-size.Seems like an inset shadow is simple enough.