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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:06:13+00:00 2026-05-24T00:06:13+00:00

Recently, I have been trying to accomplish creating a full-width jQuery slider that would

  • 0

Recently, I have been trying to accomplish creating a full-width jQuery slider that would basically display a very large image (2000×350) which would allow the image to span across even quite large monitor resolutions.

However, unlike some similar sliders such as Parallax and this jQuery Cycle example, I would like to use the entire image instead of a smaller image with a background color. The issue that I am encountering is how the slider is being shown on smaller resolutions (1024×768), as it display the entire image with scrollbars, when what I am trying to accomplish it to simply show the “center” of the image while ignoring the areas that do not appear on the page.

I am attaching a jsfiddle with a sample image (2000×350), and am wondering how I might be able to display just the area within the “960” if the page was viewed on 1024×768, and display larger portions of the image (centered) if the resolution was larger.

Any suggestions – either pure CSS or using Javascript/JQuery would be greatly appreciated.

Summary: I am trying to create a full-width jQuery image-slider that will display only the “center” of the image and ignore any of the overflow based on the user’s window size.

EDIT : This example – is what I am searching for.

  • 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-24T00:06:14+00:00Added an answer on May 24, 2026 at 12:06 am

    If your HTML is as follows:

    <div id='wrapper'>
        <img src="http://i.imgur.com/s0Gvf.png" />
    </div>
    

    Then you can center the image vertically and horizontally within the #wrapper element using the following CSS:

    html, body { 
        height:100%; 
    }
    #wrapper {
        position:relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    #wrapper img {   
        position:absolute;
        left:50%;
        top:50%;
        margin-left:-1000px;
        margin-top:-175px;
    }
    

    This will set #wrapper to the width and height of the browser window. overflow:hidden; will make anything too big that is inside it hidden. #wrapper img sets the image to vertically and horizontally align to the parent container.

    This is done by setting its top and left positions to 50% and then offsetting these positions with half the images width and height. So margin-left is - (image_width/2) px, etc.


    Edit:

    Regarding the gallery/slider, please check an updated version of your jsFiddle: http://jsfiddle.net/vMqxa/2/

    To see the end result, visit this page: http://jsfiddle.net/vMqxa/2/show/light/

    What is going on here exactly…

    To start there is #wrapper_wrapper (bad name, I know..) which is an 100% width and height div so it will fill up all of the screen.

    Within this is #wrapper which will contain all the images. This is what will be scrolled left and right to display the correct image so it needs to be as wide as all the images inside it. This means that if we have 4 images, then the width of #wrapper will be 4 * the width of the screen. This is calculated in javascript using:

    $("#wrapper").width(window.innerWidth * $(".image_wrapper").length);
    

    Next there is .image_wrapper which is a div used to hold each image. The width of this is set to window.innerWidth using javascript. It also has overflow:hidden so that anything inside it that is too big, wont be displayed.

    Finally, we have the images .image_wrapper img which are positioned using absolute positioning. They are set to left:50%; top:50%; and then using javascript we calculate the offset needed to perfectly center them. This is done with:

    $(".image_wrapper img").each(function(){
    
        $(this).css({
            marginLeft: "-" + $(this).width()/2 + "px",
            marginTop: "-" + $(this).height()/2 + "px" 
        });
    
    });
    

    This is all put together into a function that is called on page load and also when the window is resized.

    To scroll left and right, we use:

    $("#next").click(function(){
        var currentMargin = parseInt($(".image_wrapper").eq(0).css("marginLeft").replace("px","")),
            newMargin = currentMargin - window.innerWidth;
    
        $(".image_wrapper").eq(0).animate({
            marginLeft: newMargin + "px"
        });
    
    });
    
    $("#prev").click(function(){
        var currentMargin = parseInt($(".image_wrapper").eq(0).css("marginLeft").replace("px","")),
            newMargin = currentMargin + window.innerWidth;
    
        $(".image_wrapper").eq(0).animate({
            marginLeft: newMargin + "px"
        });
    
    });
    

    Note: this won’t stop scrolling if there is nothing to the left or right.

    Again, please have a look at the complete code on jsFiddle: http://jsfiddle.net/vMqxa/2/

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

Sidebar

Related Questions

Recently I have started playing with jQuery, and have been following a couple of
I've recently been trying to learn the Object-Oriented aspects of F#, and have become
So I recently have been trying to incorporate more sub forms to make the
recently I have been trying my hand at coding a game in C#. I'm
Recently I have been trying to make changes so I can do builds through
I have recently been trying to upgrade my app form Rails 2.3.8 to newly-releases
I have recently been trying to learn about basic design principles and the OCP
I have been trying to learn CakePHP's ACL stuff recently but keep getting confused,
recently I been trying to create an android app that uses JSON Objects to
Recently I have been looking at jquery/javascript solutions to emulating the placeholder attribute, but

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.