Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Background image centered, and context menu overflow

Posted on 2005-02-27
Medium Priority
Last Modified: 2012-05-05


I explain my problem. To resume, i have a background-image centered for my BODY.

I have a div that is centered too inside this body.

I use a "" context menu. When i "right-click" near a border of my window, context menu is displayed outide the window, so window is resized and backgound image is recentered depending of the new global window size (even if lift cursor appear). BUT div inside is not resized depending of the size of the document. It stay centered depending on the content of what is displayed.

How to resize my div the way the backgound do, or how to keep background image centered to what is displayed and not global window size.
Question by:eeolivier
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Accepted Solution

arantius earned 2000 total points
ID: 13416068
Online demo:

      <base href="" />
      <title>Javascript Context Menu Ex.#8 - dhtml popup menu mode</title>

      <!-- Apycom DHTML Menu -->
      <noscript><a href=>DHTML Menu, (c)2004 Apycom</a></noscript>
      <script type="text/javascript" language="JavaScript1.2" src="apymenu.js"></script>
      <script type="text/javascript" language="JavaScript1.2" src="data-popup.js"></script>
      <script type="text/javascript" language="JavaScript1.2" src="data-popup2.js"></script>
      <!-- Apycom DHTML Menu, -->

      body {
            margin: 0;
            height: 100%;
      #holder {
            width: 100%;
            min-height: 100%;
            background-image: url(img/bg.gif);
            background-repeat: repeat-y;
            background-position: center;
            text-align: center;
      * html #holder {
            height: 100%;

<body bgcolor=#FFFFFF onContextMenu="return apy_popup(1, 1000, event);">
<div id="holder">
      <div style="width: 784px;margin: 0 auto;width: 784px;text-align: center;">
            Display this window in order to see gray backgound left and right<br><br>
            Put you mouse near the right of the window. Right CLICK. A context menu should appear.
            But it appear out of the window. BUT !!! Background that is centered reajust , but not
            the DIV that contain what your are reading. How to dynamically center this div even if it is
            clicked near the border of the screen ? What javascript to raise ?

LVL 32

Expert Comment

ID: 13416073
It's a better solution to modify your right click menu so that it would show at the left side of the mouse cursor when you're at the right edge of the window.


Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question