[HELP] HTML/CSS: How to vertically align text and random border not going away
The easiest way with the most support for just that is using the line height property. Because those images are 300px tall, if you wrap the text inside a span with a class then you can add this
.vertAlignText{ line-height: 300px;}
This will align it in the centre vertically. Be warned, this will not work on multiple lines of text. So, some alternatives are:
Give the parent div the css of display:table; and the child (the text) the CSS of display:table-cell; Then you should be able to successfully use vertical-align:middle; on the text. I didn't use this method because browser compatibility isn't as good and requires a few hacks for the usual suspect browsers
Another alternative is to use the translate x and translate y properties. I personally believe that unless the next CSS spec contains something that expressly centres everything the way you want it to, this will be how you centre everything in the future. Right now it's a bit not so good, it's not supported currently in many browsers, at least, not properly. But it's simply:
.centeredThing{ position: relative; top: 50: transform: translateY(-50%);}
This works like a charm^^^ When it does work
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now