I would like to center a text element (in this case, the h2 sub-headline) by having it ignore the floated image to the left. My preference would be for the h2 sub-headline to vertical center-align with the h1 headline. Is there any way to do this with CSS alone?
Here is a sample layout:
http://tinyurl.com/84otx8y
Note: the width and height of the sample image may change.
I would like to center a text element (in this case, the h2 sub-headline)
Share
You want to ignore the floating element? That’s possible, however, I would not recommend this, as this will create an ugly result if your
h2headline is to wide:Note that this solution will have the
h2border on top of the image. You can prevent this by usingposition:relative;z-index:4on your floating image.