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 3500734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:46:16+00:00 2026-05-18T12:46:16+00:00

This may be an easy one. I looked through previous questions (and other places

  • 0

This may be an easy one. I looked through previous questions (and other places on the web) but cannot find a good solution for my current problem.

I am trying to have a centered drop down menu with CSS based on a list. Nothing very complicated.

This one has a very simple solution for it, but I cannot find what I am doing wrong.

I have two problems at this point (it’s mostly in the first list, have not really looked at the links in the list yet) :
(1) I would like the list coming down to have a background as a large rectangle that encompass all the items in the sub-list
(2) the items in the sub-list are “truncated”, a new line is inserted so that the width does not exceed the width of the list title.

Thanks.

The CSS part

#navbar ul {
    text-align: center;
    width: 100%;
    font-variant: small-caps;
    padding: 5px 0;
    margin-top: 0;
    margin-left: 0;
    }
#navbar ul li {
    background-color: #ccc;
    margin-right: 2%;
    color: #069;
    text-decoration: none;
    position: relative;
    display: inline;
    padding: 5px 4px;
    }
#navbar li a {
    text-decoration: none; }
#navbar li ul {
    display: none; 
    }
#navbar li:hover ul, #navbar li.hover ul {
    display: block;
    position: absolute;
    text-align: left;
    margin: 8px 0 0 0;
    padding: 0;
    background-color: #eee; }
#navbar li:hover li, #navbar li.hover li {
    padding: 4px 0;
    clear: left;
    }
#navbar li:hover li a, #navbar li.hover li a {
    background-color: #eee;
    border-bottom: 1px solid #fff;
    color: #000; }
#navbar li li a:hover {
    background-color: #333; }

The HTML part

   <div id="navbar">
    <ul>
        <li>
            <a href="#" title="">Link 1</a>
        <ul>
                <li>item 1.1 and more</li>
                <li>item 1.2</li>
                <li>item 1.3</li>
                <li>item 1.4 truncated?</li>
                <li>item 1.5</li>
                <li>item 1.6</li>
        </ul>

        </li>
        <li>
            <a href="#" title="">Link 2</a>
            <ul>
                <li><a href="#" title="">Link 2.1</a></li>
                <li><a href="#" title="">Link 2.2</a></li>
                <li><a href="#" title="">Link 2.3</a></li>
                <li><a href="#" title="">Link 2.4</a></li>
                <li><a href="#" title="">Link 2.5</a></li>
                <li><a href="#" title="">Link 2.6</a></li>
            </ul>
        </li>
        <li>
            <a href="#" title="">Link 3</a>
            <ul>
                <li><a href="#" title="">Link 3.1</a></li>
                <li><a href="#" title="">Link 3.2</a></li>
                <li><a href="#" title="">Link 3.3</a></li>
                <li><a href="#" title="">Link 3.4</a></li>
                <li><a href="#" title="">Link 3.5</a></li>
                <li><a href="#" title="">Link 3.6</a></li>
        </ul>
    </li>
</ul>
</div>
  • 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-18T12:46:17+00:00Added an answer on May 18, 2026 at 12:46 pm

    1) It looks like you already have a background rectangle. Do you just want more padding?
    If so, add padding like so:

    #navbar li:hover ul, #navbar li.hover ul {padding:10px}

    2) As for truncating, try

    #navbar li:hover ul, #navbar li.hover ul {word-wrap: break-word;}

    I would however suggest you look take a look at this article, to help you with drop down menus: http://matthewjamestaylor.com/blog/centered-dropdown-menus

    EDIT: Unfortunately, word-wrap is a CSS3 property, and is not supported by all browsers. Additionally, word wrap with cross browser CSS does not appear to be trivial. This post word wrap in css / js has some more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be super easy to solve but I can't find the correct google
This may be an easy question, but if it is one i haven't found
This may be an easy one, but it escapes me at the moment. I
This may be an easy one for some of you, but I am having
Sorry, this may be an easy one, but it has me stumped. I'm trying
I am fairly new to OSX development, so this may be easy but google
This may be an easy answer but I've been staring at it for too
This may seem an easy question, but not to me, also a search has
This may be an extremely easy question but I can't get my head around
This may be a simple question but I can;t find the answer anywhere. Here

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.