Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 812533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:13:08+00:00 2026-05-15T01:13:08+00:00

I need to center align a horizontal menu. I’ve tried various solutions, including the

  • 0

I need to center align a horizontal menu.
I’ve tried various solutions, including the mix of inline-block / block / center-align etc., but haven’t succeeded.

Here is my code:

<div class="topmenu-design">
    <!-- Top menu content: START -->
    <ul id="topmenu firstlevel">                                                                                       
      <li class="firstli" id="node_id_64"><div><a href="#"><span>Om kampanjen</span></a></div></li>
      <li id="node_id_65"><div><a href="#"><span>Fakta om inneklima</span></a></div></li>
      <li class="lastli" id="node_id_66"><div><a href="#"><span>Statistikk</span></a></div></li>
    </ul>
    <!-- Top menu content: END -->
</div>

UPDATE

I know how to center align the ul within the div. That can be accomplished using Sarfraz’s suggestion.
But the list items are still floated left within the ul.

Do I need Javascript to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:13:09+00:00Added an answer on May 15, 2026 at 1:13 am

    From http://pmob.co.uk/pob/centred-float.htm:

    The premise is simple and basically just involves a widthless float wrapper that is floated to the left and then shifted off screen to the left width position:relative; left:-50%. Next the nested inner element is reversed and a relative position of +50% is applied. This has the effect of placing the element dead in the center. Relative positioning maintains the flow and allows other content to flow underneath.

    Code

    #buttons{
        float:right;
        position:relative;
        left:-50%;
        text-align:left;
    }
    #buttons ul{
        list-style:none;
        position:relative;
        left:50%;
    }
    
    #buttons li{float:left;position:relative;}/* ie needs position:relative here*/
    
    #buttons a{
        text-decoration:none;
        margin:10px;
        background:red;
        float:left;
        border:2px outset blue;
        color:#fff;
        padding:2px 5px;
        text-align:center;
        white-space:nowrap;
    }
    #buttons a:hover{ border:2px inset blue;color:red;background:#f2f2f2;}
    #content{overflow:hidden}/* hide horizontal scrollbar*/
    <div id="buttons">
        <ul>
            <li><a href="#">Button 1</a></li>
            <li><a href="#">Button 2's a bit longer</a></li>
            <li><a href="#">Butt 3</a></li>
            <li><a href="#">Button 4</a></li>
        </ul>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to center align images (variable width and height) inside block level elements
I have a horizontal <ul> and I need to center each <li> in it
I need to send hundreds of newsletters, but would like to check first if
I have been trying to make the sub-menu horizontal. In my HTML it looks
i am trying to center my horizontal <ul> inside a <div> (the yellow stripe
Im using a td.Image class that has text-align:center; to center images in a table
I have a page with the container in a table I need to align
I need to center some text inside a <div> or <span> tag. I've set
Need a function that takes a character as a parameter and returns true if
Need a way to allow sorting except for last item with in a list.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.