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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:51:56+00:00 2026-06-10T21:51:56+00:00

I wanna center a image within a div that has overflow hidden Like a

  • 0

I wanna center a image within a div that has overflow hidden

Like a frame and then picture no matter size are centered.

<div class="holder">
   <div id="frame">
      <img src="http://www.travelblog.org/Wallpaper/pix/tb_fiji_sunset_wallpaper.jpg" class="centerme"/>
   </div>
</div>​

See picture for more info:
enter image description here

standard state is how it always gonna be with overflow:hidden;

but need it to always center even its a picture 3 times bigger than the frame

*heres the JSfiddle
http://jsfiddle.net/UL3qp/4/

*EDIT
Last needed is to loop this incident

  • 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-10T21:51:57+00:00Added an answer on June 10, 2026 at 9:51 pm

    Centering the image with jQuery is simple – via setting a positive or negative margin-left property:

    $(document).ready(function(){
        var fwidth = $('#frame').width();
        var iwidth = $('#frame img').width();
        $('#frame img').css('margin-left', Math.floor((fwidth-iwidth)/2));
    });
    

    With only the pure CSS it can be done via a background image css property instead of using the img tag.

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

Sidebar

Related Questions

I have a table like that. And I wanna get the just text FOO
Actually i wanna show the JinternalFrame in the center of the JDesktopPane and i
I wanna check sharepoint title first and see if the lib doesn't have that
I wanna to detect an input tag that its name is: some[en] in jquery.
I wanna to achieve an effect like a fired blue ball (ball with energy)
I wanna link a movie clip which has instace name test1 to a external
I wanna use a TUI over telnet connection between two Linux boxes like ncurses,
I wanna pass parameter to Custom View at runtime. is that possible? <custom.analog.clock.AnalogClock1 android:id=@+id/clock
I wanna create a server control like the following : <%@ Register Assembly=MdsAccordionMenu Namespace=MdsAccordionMenu
I've been looking for a way to center a div with a set max-width.

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.