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

  • Home
  • SEARCH
  • 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 8597395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:54:13+00:00 2026-06-12T00:54:13+00:00

I would like to center some div which has background image. There is problem

  • 0

I would like to center some div which has background image. There is problem with response of this div, because if I set width on 80% and height on 80% the bg-image is not on center. I tried everything, but the picture can’t just stand on center and if the browser is smaller or bigger this is very big problem.

So if you look at the picture

block on center

I want to make this white block responsive.

There is a little of css which I’ve already written, but for now is non-responsive:

top: 20%;
left: 30%;
display: block;
position: absolute;
background: url(images/background.png) no-repeat;
background-size: 750px 417px;
width: 750px;
height: 417px;
  • 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-12T00:54:14+00:00Added an answer on June 12, 2026 at 12:54 am

    I wanted to do the same thing 2 years ago, there’s the solution:

    Because you want it responsive, you may use the @media function in CSS3. Like this:

    @media (max-width: 480px) {
        #div {
            top: 50%; /* IMPORTANT */
            left: 50%; /* IMPORTANT */
            display: block;
            position: absolute;
            background: url(images/background.png) no-repeat center center;
            width: 750px;
            height: 417px;
    
            margin-top: -208.5px; /* HALF OF THE HEIGHT */
            margin-left: -375px; /* HALF OF THE WIDTH */
        }
    }
    

    The max-width you use is the maximum width of the device screen. You just copy it and change the width, height, margin-left and margin-top for the image. Also, you should change the background tag!

    It will center the image on the page.

    You can see an exemple at: Créations MicroWeb – Carrières. The image is totally centered even if you change the window side.

    You can add overflow: hidden; on the body to make the page unscrollable when the resolution is too low. Like I did.

    EDIT: JSFiddle

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

Sidebar

Related Questions

The web designer has given me HTML which looks like: <div .... style=background: transparent
I have some code on my page that looks like this: <div class=img-center> <img
I would like to center a text element (in this case, the h2 sub-headline)
I have a #info div element which shows some text strings like below: <body>
I would like to make both the background image as well as the contents
I would like to center a title with respect to a plot matrix (and
I have an aspx Login control and I would like to center it on
I would like to Show my Messagebox in the center of its parent form.
I've made a menu strip that I would like fixed to the bottom center
I have written a plugin for Windows 7 Media Center, and I would like

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.