I would like to vertically align text next to an image in a before pseudo-element.
The way it's working now is that my image is displayed to the left of my text, but both the image and text sit on the same baseline. I tried using vertical-align
, but it didn't work. I think the issue is that content is treating both the image and text as one block element.
* {
margin: 0;
padding: 0;
}
body {
background-color: #000000;
}
header {
background-color: #202830;
color: #ffffff;
width: 100%;
}
header::before {
align-items: center;
background-color: #581845;
color: #E88968;
justify-content: center;
content: url("https://stackoverflow.com/favicon.ico") " This is some text";
display: flex;
height: 72px;
width: 100%;
}
p {
padding: 16px;
}
<header>
<p>This is my header</p>
</header>
In the snippet, you can see that "This is some text" is aligned with the baseline of the image. I want it to be centered with the image.
Update: This code works in Firefox 82.0.3 (32-bit) on Windows 10, but does not work in Chrome 86.0.4240.198 (64-bit) on Windows 10 or Edge 87.0.664.47 (64-bit) on Windows 10.