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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:10:22+00:00 2026-06-09T00:10:22+00:00

I am currently working with a jquery plugin for setting my background image. The

  • 0

I am currently working with a jquery plugin for setting my background image. The issue i am having is with the CSS/JQuery making the page in-proportionate. My content lies inside the #container div so I have set its position to absolute(originally was relative). How can I have the content of the page be aligned in the center and keep the properties of a 100% height? EXAMPLE

This is before the jquery plugin- CSS 100% height- EXAMPLE

Jquery Background plugin

<script>
(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);        

    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();

      var winwidth = $(window).width();
      var winheight = $(window).height();

      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;

      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;

      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });     
      }
    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };
})(jQuery)
</script>

CSS related to the issue

#container {
    position: relative;
    margin: 0 auto;
    width: 945px;
    background: #f0f0f0;
    height: auto!important;
    height: 100%;
    min-height: 100%;
    border-right: 15px solid #000;
    border-left: 15px solid #000;
}

.fullBg {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
}

HTML/Inline JS to call function

<img src="images/raven_bg.jpg" alt="" id="background" />
<div id="container">
</div>
<script>
$(window).load(function() {
    $("#background").fullBg();
});///this comes right before the closing body tag
</script>
  • 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-09T00:10:24+00:00Added an answer on June 9, 2026 at 12:10 am

    This centers it –

    #container { 
        margin-left: 50%;
        left: -488px;
    }
    

    it’s kind of hacky, but it works.

    50% shift (to keep it centered based on width)

    half of width, plus border = 478.5 (or 488) to keep it centered in frame. And of course, with “left” only works because it’s got position: relative; attached to it

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

Sidebar

Related Questions

Here I am working with jquery data table plugin in asp.net page I'm currently
I am currently working with the jQuery validation plugin , and I want to
I'm currently working with ckeditor and i'm using the jquery plugin for this editor
I am working with the jQuery Calculation Plugin on a page where I do
I am working with CSS sprites and the jQuery plugin spritely . I have
I'm currently working with a JQuery Plugin called Raty (among many others), as normal
I'm currently working with JQuery plugin for struts2. I would like to know how
I'm currently working on a project using javascript and python with Jquery Datatables plugin
I'm currently making a jQuery Plugin for a Redirect Timer and it is really
I'm currently working on a jQuery plugin and I'm wondering if it would be

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.