I want to have a paragraph break with an emoji in the middle, but it keeps showing only the bottom half of the emoji. The top half gets hidden behind the hr-tag line (see image).
This is my CSS:
hr {
width: 100%;
margin: 5em 0em 5em 0em;
padding: 0;
border: none;
border-top: medium double #E3E3E1;
color: #675757;
text-align: center;
}
hr:after {
content: "˗ˏˋ☕ˎˊ˗";
display: inline-block;
position: relative;
font-size: 25px;
padding: 0 10px;
top: -0.7em;
}
I want it to look like this (made with ms paint lol)
On the after-section I tried these:
-
changing display to "block"
-
adding a background colour to the after-section, but that still showed only the bottom half of it.
-
adding background-color: transparent
-
adding "border: 0;"
-
adding "z-index: 1;"
On the hr-section I tried these:
- removing the color
All of these solutions led to the same result as in the screenshot above: the top half is hidden behind the line. Why?
It could be that I didn’t use the right combination of the above solutions. I don’t understand CSS enough to know.
Edit: noticed that my question got closed because there’s been a similar question. The answers to that one all point to a H2-solution though, where I’d put the emoji in the HTML/text. Is there no way to put the emoji in the CSS?
The reason is: I want it to be accesible for screenreaders, which would understand the HR-tag, but would try to read out the HTML everytime, which gets annoying.
2
Answers
The issue is basically with the positioning of the emoji and the
hr
tag overlapping. One way to resolve this(as I would do) is to use:before
instead of:after
to applytop
,left
andtransform
properties. Something like: