Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Please help with center aligning my ul

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #264657
    ComputerGuy
    Participant

    I’m a Systems Administrator that’s trying to incorporate some HTML/CSS into some of my PowerShell report scripts. I’m fairly new to CSS, so I’ve watched some tutorials and went over some examples online. I have a base design of a menu that is almost where I want it, but I can’t center the menu. I’ve looked on the web, searched youtube videos, but I can’t incorporate the examples into my CSS.

    Thanks in advance for any help.

    See the Pen eyWBag by ComputerGuy (@TheComputerGuy) on CodePen.

    https://production-assets.codepen.io/assets/embed/ei.js

    #264658
    Shikkediel
    Participant

    I think there are several ways to get there, of which display: inline-block on ul and text-align: center on the parent is probably easiest:

    codepen.io/anon/pen/JMNWKQ

    #264688
    ComputerGuy
    Participant

    Thank you so much, that worked perfectly. I really appreciate it. I’m going to keep that as my base, and experiment on it so that I can understand it better. Again, thank you.

    #264689
    Shikkediel
    Participant

    No problem, it was a bit tricky because of the combination of a full width ul and li elements that are floated. The latter makes it hard to center the child elements – so I went for the parent. That needed the width: 100% removed so its size would adapt to that of the li children using display: inline-block. Then the last step was to center it through the parent, text-align being the designated option for centering inline elements.

    Hope that explains it a bit more. Cheers.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.