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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:04+00:00 2026-05-22T20:51:04+00:00

HTML: <div class="imgcontainer"> <ul> <li><img src="1.jpg" alt="" /></li> <li><img src="2.jpg" alt="" /></li> ….. </ul>

  • 0

HTML:

<div class="imgcontainer">
    <ul>
            <li><img src="1.jpg" alt="" /></li>
            <li><img src="2.jpg" alt="" /></li>
            .....
    </ul>
</div>  

I’m coding a simple gallery page by creating unordered list and each list item of it contains an image.

    ul li {
        float: left;
    }

I set the width of the container as "max-width" so I can make possible to fit the list items (images) to the browser width.. meaning that they will be re-arranged when the browser window re-sized.

    .imgcontainer{
        max-width: 750px;
    }

Now the problem is those images or list items are not aligned to center, they are aligned to the left of .imgcontainer body (colored gray in the attached link below), leaving a space on the right when the window re-sized!

enter image description here

How can I center those images every time the window resized?

Here’s the whole page/code you can preview it or edit it at JS Bin

http://jsbin.com/etiso5

  • 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-22T20:51:04+00:00Added an answer on May 22, 2026 at 8:51 pm

    Remove float:left and use display:inline so that you can use text-align:center. Set the font size to zero so that you don’t have white-space between the images.

    ul {
        font-size:0;
        text-align:center
    }
    ul li {
        display:inline;
        zoom:1
    }
    .imgcontainer {
        max-width:750px;
        margin:0 auto
    }
    

    The zoom is a hack for old IE versions. This is however not a valid CSS property, so won’t go through the W3C validator.

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

Sidebar

Related Questions

Hi I've got something like the following HTML: <div class="container"> <img src="first.png" /> <img
Lets say i have the following web page: <html> <body> <div class="transform"> <span>1</span> </div>
i have this simple html: <div id="tree"> <div class="roi"> <ul> <li>text1</li> <li>text2</li> <li>text3 <ul>
I have a HTML document like below: <td> <div class="commentLink"> <a href="javascript:ShowBox()">Show</a> </div> <div
First my code: Html <div class="product_image m2" id="m2"><a href="#" id="10" class='multi2'>test..</a></div> JS $(document).ready(function(){ $("#m2
The HTML which should be produced after manipulation: <div class="comments_action_207"> <div class="list_item_comments list_item_comments_207"> <div
Code : HTML <a id="go" href="javascript:void(0);">Start</a> <div id="container"> <div class="example" id="example1">1</div> <div class="example" id="example2">2</div>
I have the following HTML: <div class="selfClear" style="float: left; border: 1px solid black;"> ...floated
Well, I got something like this: HTML: <div id="main" class="underline" >Hello</div> JavaScript: $('div').live('click', function(){
i have my html something like this... <div class = content> <div class =

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.