- This topic is empty.
-
AuthorPosts
-
October 29, 2014 at 7:29 pm #187300DoodayerParticipant
Hi I’m having issues with getting text, and images in my navigation bar to center out properly. for some reason, I can’t get anything to center out vertically in my navigation bar. Any thoughts or ideas?
October 29, 2014 at 8:28 pm #187301October 30, 2014 at 2:23 am #187310Paulie_DMemberAny thoughts or ideas?
Without code…nope.
A minimal example in Codepen.io is the way we can assist.
See the Tips box —>
Help us help you.
October 30, 2014 at 8:50 pm #187381DoodayerParticipanthere ya go. I just can’t figure out how to vertically center my text, and images in the nav bar
http://codepen.io/Doodayer/pen/vGyHpthanks for helping guys!
October 30, 2014 at 9:54 pm #187383__Participantin order for
vertical-align:middle
to have any effect, yourli
s need to be displayed asinline-block
(not justinline
).In addition, the image and adjacent text would both need to be inline-block (you’d need to wrap the text in an element, a
span
would be most appropriate) before you could vertically align them.October 31, 2014 at 11:12 am #187441DoodayerParticipantI’m pretty new to html, and css so what do you mean by wrap them in an element?
October 31, 2014 at 4:43 pm #187451__ParticipantI’m pretty new to html, and css
Sounds like you need to learn, then. : )
what do you mean by wrap them in an element?
I mean the text would need to be contained in another element (a sibling element of the
img
) if you wanted to vertically center it with the image.vertical-align
does not have any effect on plain text.October 31, 2014 at 5:51 pm #187453DoodayerParticipantthank that, and it worked for the most part. now the problem is the image and the first word are centered, but the rest remain below. reasons?
edit: the image still doesn’t center all that well, could this be due to it using the top left corner of the image as its center point, instead of actually using the center of the image?
October 31, 2014 at 6:07 pm #187454__Participantthe image and the first word are centered, but the rest remain below.
Do you mean “the rest” of the
li
s? That’s not what I see. Do you see this in my codepen? if so, what browser are you using?the image still doesn’t center all that well, could this be due to it using the top left corner of the image as its center point, instead of actually using the center of the image?
These rules will align both the image and the
span
(which contains your text) on a single line through the middle. Conceptually, like this:+-----+ +----------------+ ----| img |----| span with text |---- <-- vertical align: middle +-----+ +----------------+
It’s a bit hard to tell in your codepen, because the image is not actually loaded (you would need to give a full URL, since the image is not hosted on codepen.io). I’ve replaced the image with a 20×20 image in my codepen; have a look.
October 31, 2014 at 6:15 pm #187455DoodayerParticipantI’m using firefox to test it. Still for some reason it displays them lower than the image and first word. heres a screen shot:
http://i.imgur.com/fAvF4Df.jpgOctober 31, 2014 at 11:34 pm #187456__ParticipantIs that screenshot from your site, or the codepen? does it look correct in the pen?
November 1, 2014 at 6:22 am #187469DoodayerParticipantif you look closely at your codepen, the first word is still lower than the rest. Why is this?
and that was a screen shot from the actual test on firefox
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.