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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:56:05+00:00 2026-06-08T05:56:05+00:00

I have a problem concerning CSS and HTML. I’m trying to wrap a DIV

  • 0

I have a problem concerning CSS and HTML.

I’m trying to wrap a DIV around another element (an UL in this case) and having it wrap around it and at the same time keeping both centered. As an added bonus I can’t set a specific width since the width of the content inside the wrapping DIV have to be dynamic (since this is basically a template).

I’ve tried floating, and that works as far as wrapping goes, but then the thing ends up either to the right or to the left.

I’m going a bit crazy over this, and google is no help!

Thanks in advance!

UPDATE:

Sorry about not including code or images. This is what I’m trying to do illustrated with images:

One state of the UL width

Another state of the width

The wrapping DIV can’t stretch the full width of the container. It has to wrap around the UL.

The dark grey is the DIV around the UL. I need the DIV to wrap around the UL (which has a horizontal layout) no matter the width of the content, since like I said above, the content of the UL is going to by different from time to time. The text in the LIs are going to change.

I also need it to be centered. I’ve made it work with float left and float right, but I need it to be centered.

This is the code I’m currently using for the container DIV and the UL and LI elements:

#container{
    height: 100px;
    width: 500px;
    font-size: 14px;
    color: #grey;
    display: table-cell;
    vertical-align: middle;
}
#container ul{
    text-transform: uppercase;
    text-align: center;
    font-weight: bold;
}
#container li{
    background: url(checkmark.png) center left no-repeat;
    display: inline;
    padding-left: 20px;
    margin-right: 5px;
}
#container li:last-child{
    margin-right: 0;
}
  • 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-06-08T05:56:07+00:00Added an answer on June 8, 2026 at 5:56 am

    UPDATED

    I got it. Is it this you were looking for?? http://jsfiddle.net/vZNLJ/20/

    #wrapper {
        background: #ccc;
        margin: 0 auto; /* to make the div center align to the browser */
        padding: 20px;
        width: 500px; /* set it to anything */
        text-align: center;
    }
    #wrapper ul {
        background: #aaa;
        padding: 10px;
        display: inline-block;
    }
    #wrapper ul li {
        color: #fff;
        display: inline-block;
        margin: 0 20px 0 0;
    }
    #wrapper ul li:last-child {
        color: #fff;
        display: inline-block;
        margin: 0;
    }
    <div id="wrapper">
        <ul>
            <li>Menu</li>
            <li>Menu</li>
            <li>Menu</li>
        </ul>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem concerning multiple file uploads in javascript. I am trying to
I have problem concerning python packages and testing. I'm writing an application using wx
I have a problem concerning a HashMap in Java. To explain the problem in
I have a problem concerning the width of a DialogPreference in Android. According to
i have a problem concerning a select query in MYSQL i have two different
I am using LaTeX and I have a problem concerning string manipulation. I want
i am currently working on a facebook game and i have a problem concerning
I have quite a problem concerning the use of relational database concepts in Delphi
I'm a beginner concerning socket programming and I have a problem when I send
I have a small problem. I am trying to align two divs side by

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.