Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
messisbugomessisbugo
3,334 PointsHow to center a list into his parent without using margin or padding.
Hi, I only want to center the list into the nav
HTML:
- nav1
- nav2
- nav3
CSS (colors only used to identify the elements):
body { width: 960px; margin: auto; background-color: tomato; }
nav { background-color: lightblue; }
li { list-style: none; display: inline-block; font-size: 2em; position: relative; left: 320px; }
I don't think that it is the right way.
5 Answers
John Locke
15,479 PointsDid you try text-align: center ?
messisbugomessisbugo
3,334 Pointssure but it doesn't works. LI is the child of UL so, first I centered the UL next I tried to center the LI into UL. But nothing....
Kevin Korte
28,149 PointsI'm a little confused as to what you are after. Is it something like this?
messisbugomessisbugo
3,334 Pointsgreat thank you. I don't know why I was trying to center the LI element.
Jonathan Bouknight
3,666 PointsI've spent hours trying to figure out the same problem - thank you for posting this!!!