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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:47:21+00:00 2026-05-24T11:47:21+00:00

OK, here was my original question, where I’ve left out the most important thing:

  • 0

OK, here was my original question, where I’ve left out the most important thing: to horizontally center the image, if the screen is bigger than max-width.

So far the classic trick for margin: auto doesn’t work, because then width: 100% isn’t the screen anymore.

#main {
margin: 0 auto;
width: 1024px;
background-color: red;
}

#bigimage {
max-width: 1024px;
width: 100%;
}   


<div id="main" role="main">
    <img src="img/bigimage.jpg" id="bigimage">
</div>

So I’m looking for an other solution. Any idea how to make max-width and horizontal centering work together?

Update:

OK, I’m almost there:

#main {
width: 100%;
text-align: center;
}

#bigimage {
max-width: 1024px;
width: 100%;
}

And it works great in all browsers, except IE8. Even IE 7 is OK! IE8 resizes the image without keeping the aspect ratio! I mean it makes it max-width wide but original width high. Can you help me how to make it not distort in IE8?

Also, a live site, with 500px max-width:
http://ilhaamproject.com/

  • 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-24T11:47:22+00:00Added an answer on May 24, 2026 at 11:47 am

    if your image have an static aspect ratio then it can be done with max-height. If you add max-height to your image based on the 1024px width (726px for 4by3 aspect ratio) then it would be fine in every browser. See the fiddle before applying max-height and after that. I just used 400px width instead.

    HTML:

        <div id="container">
            <img id="bigDude" src="http://www.ladygagapic.info/wallpaper/flower-17.jpg" />
        </div>
    

    CSS:

    #container{text-align:center; border:1px solid gray;}
    #bigDude{max-width:400px; width:100%;}
    

    BUT if your images are not in same size or aspect ratio you maybe need some JavaScript just like how Facebook forced to do that.

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

Sidebar

Related Questions

EDIT: I figured out the answer to the original YUI3 question I posted here,
This question is sort of a follow-up to my original question here . Let's
Ok, here was my original question; Table one contains ID|Name 1 Mary 2 John
My original question can be found here , for which I've gotten some great
The answere is here, and my original question is below..... Changing the document workspace
Original question: here Upon searching i need to alter the results across rows which
Original Question: Database Design: need composite key + foreign key Here's what I need:
I did a poor job of explaining my original question, so here's a second
I asked the original question here , and got a practical response with mixed
[EDITED: I left the original question below, with some more context and code to

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.