问题
I have a fairly long H1 title containing a link with a pseudo ::before
element that I want to wrap to two lines correctly. Here's what I need:
- A pseudo
::before
element on ana
link inside of an H1 (it needs to be clickable, so can't be on the H1).- I have this done successfully.
- The text to wrap normally and align with the left side of the first word.
- This is where the problem is.
See my testing codepen here: http://codepen.io/dmoz/pen/EaZqKv
Seems like it should be a simple fix, but I can't think of what controls how the text wraps. Any thoughts?
回答1:
Adding float:left
to pseudo element will do it.
Check updated demo
回答2:
Right now your image is being displayed as an inline element (think of it flowing like a single character like an 'A' or a '9'). To have text wrap around it, you need it floated. I'm not sure if this forces block level formatting, but it does force other elements to
http://codepen.io/anon/pen/MYJNEp
Like so:
.site-title a:before {
...
float:left;
}
Edit: remember to clear your float if you have other elements that appear after the your h1
(highly likely)
来源:https://stackoverflow.com/questions/27909313/getting-h1-text-to-wrap-beside-a-before-pseudo-element