Jump to content
Nelson Tan

How to align words to center of navigation bar?

Recommended Posts

Hi, in this hover dropdown menu example (https://www.w3schools.com/howto/tryi...ropdown_navbar), the menu words are aligned left starting from 'Home'. Where do you place the 'text-align: center' statement in the coding to shift all the words towards the center of the navigation bar? Somehow it isn't as simple as it seems to me. For your benefit, I attach sample coding in example.html. Thanks for your advice.

example.html

Edited by Nelson Tan

Share this post


Link to post
Share on other sites

Since they use the float property text align has no effect. To center the menu you will have to remove the float property and set the display of the menu items to inline-block. Then you can use text-align on the container. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...