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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:13:28+00:00 2026-06-13T19:13:28+00:00

I have a document where I use a 40×40 pixel repeated background texture on

  • 0

I have a document where I use a 40×40 pixel repeated background texture on the body.

Then I have a div with a set width and height and centered with margin: 40px auto 0 auto;

Now, the background image of this div (let’s say it’s 960×500, same as the element itself) has the same texture as the body. I cannot use a transparent png, because of a graphical effect I’m trying to achieve with this image.

However, for the effect to work, the background of the div needs to be seamless with the texture of the body. The user should not even be able to tell that there is a separate block element there; just an endless sea of the texture, with a detail in the middle of it all.

This becomes difficult as the div is centered, and as such, its horizontal distance from the left varies.

How can I make sure that the background texture on the body always matches the simulated texture in the div to the pixel, regardless of page width?

I’m not scared to use a JS solution if necessary, but obviously would prefer a pure CSS solution.

  • 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-13T19:13:29+00:00Added an answer on June 13, 2026 at 7:13 pm

    What you want to do is to set the background image on the body element to start in the middle. So:

    body {
        background: url(to/your/tile.png) 50% 0;
    }
    

    This means that no matter how the window is resized, you will have a predictable area within the repeating pattern.

    You’ll then have to tailor the containing div’s background to make the tiling in the body.

    Here is some code showing how this method would work: http://jsbin.com/olabos/2/edit. Note how resizing the window does not put the pattern out of sync. Hover over the middle of the preview to see where the wrapping div is.

    NOTE: some caveats to this technique, depending on how the browser handles half a pixel, you will get a 1pixel difference in the background. I don’t know of another technique that will solve your problem, so hopefully you can live with being 1px off.

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

Sidebar

Related Questions

if I use: jQuery(document).ready(function() { console.log($(this)); }); then in console I have object: [Document
I'm trying to use document.querySelectorAll for all checkboxes that have the value attribute set.
I have been trying to use the document.getElementByID to pull information from an HTML
I have an XML document that includes XPath expressions that I need to use
I have a word document with a bookmark. I use the bookmark to get
i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update
I have a one-page OpenOffice document which is a POD template. Basically, I use
I have a document with a field marked for persistence as a Collection use
Hey there, I have 20 divs floated left with different height. I use this
I'm trying to set the width and height of an element with javascript 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.