Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Page Fade Out To Focus On Popup

Page Fade Out To Focus On Popup

Scheduled Pinned Locked Moved Web Development
htmldatabasecomjsontutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abydosgater
    wrote on last edited by
    #1

    Hi, The best way I can explain this is to just show you. If you go to this site, http://www.extjs.com/examples/explorer.html#messagebox , (I know its an Ajax framework) and click on any of the buttons (Confirm, Prompt). When you click the button, a dialog box pops up, But the rest of the page fades out and cant be interacted with. This is to bring the users focus onto the dialog box. Now, I know to get the fade effect I have to: 1) add a div to the body tag 2) set its background to black 3) set its opacity to 0.1 4) set its z-index to something like 1000 What I dont understand is how to make it so that the user cannot interact with the other controls on the page. As long as the dialog is showing, the user cannot interact with the rest of the page hidden behind it. But if I add this to my own HTML page. Just a div with width/height 100% and background/opacity black/0.1.. The user can still click buttons or edit textboxes on the page? Does anyone know how is this achieved? Thanks, Andyyy

    enhzflepE P 2 Replies Last reply
    0
    • A Abydosgater

      Hi, The best way I can explain this is to just show you. If you go to this site, http://www.extjs.com/examples/explorer.html#messagebox , (I know its an Ajax framework) and click on any of the buttons (Confirm, Prompt). When you click the button, a dialog box pops up, But the rest of the page fades out and cant be interacted with. This is to bring the users focus onto the dialog box. Now, I know to get the fade effect I have to: 1) add a div to the body tag 2) set its background to black 3) set its opacity to 0.1 4) set its z-index to something like 1000 What I dont understand is how to make it so that the user cannot interact with the other controls on the page. As long as the dialog is showing, the user cannot interact with the rest of the page hidden behind it. But if I add this to my own HTML page. Just a div with width/height 100% and background/opacity black/0.1.. The user can still click buttons or edit textboxes on the page? Does anyone know how is this achieved? Thanks, Andyyy

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      A couple of things that come to mind. Are you declaring the div tag at the start of the page html? (i.e before the content it has to obscure) Are you remembering to make the div's position absolute, and it's z-index a higher number than the content to be obscured? Here's my css and body

      #overlay
      {
      background: #000;
      opacity: 0.5;
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 100%;
      z-index: 100;
      cursor: pointer;
      cursor: hand;
      display: none;
      }

      #box
      {
      background: yellow;
      position: absolute;
      width: 33%;
      height: 33%;
      left: 1px;
      top: 1px;
      z-index: 101;
      cursor: crosshair;
      display: none;
      }

      <body>
      <div id="overlay">Overlay</div>
      <div id="box" onclick="onBoxClick();" onmouseover="styleElem(this, 'red');" onmouseout="styleElem(this, 'yellow');">Box</div>
      <div>
      <h1>This is some content</h1><br>
      <input type=button id="myBtn" onclick="onBtnClick();" value="Show"/>
      </div>
      </body>

      If this doesn't help, I can post the full source (~300 lines)

      A 1 Reply Last reply
      0
      • enhzflepE enhzflep

        A couple of things that come to mind. Are you declaring the div tag at the start of the page html? (i.e before the content it has to obscure) Are you remembering to make the div's position absolute, and it's z-index a higher number than the content to be obscured? Here's my css and body

        #overlay
        {
        background: #000;
        opacity: 0.5;
        position: absolute;
        top: 0px;
        left: 0px;
        width: 100%;
        height: 100%;
        z-index: 100;
        cursor: pointer;
        cursor: hand;
        display: none;
        }

        #box
        {
        background: yellow;
        position: absolute;
        width: 33%;
        height: 33%;
        left: 1px;
        top: 1px;
        z-index: 101;
        cursor: crosshair;
        display: none;
        }

        <body>
        <div id="overlay">Overlay</div>
        <div id="box" onclick="onBoxClick();" onmouseover="styleElem(this, 'red');" onmouseout="styleElem(this, 'yellow');">Box</div>
        <div>
        <h1>This is some content</h1><br>
        <input type=button id="myBtn" onclick="onBtnClick();" value="Show"/>
        </div>
        </body>

        If this doesn't help, I can post the full source (~300 lines)

        A Offline
        A Offline
        Abydosgater
        wrote on last edited by
        #3

        Ah perfect! Thank you so much. This works perfectly :) Thank you!

        1 Reply Last reply
        0
        • A Abydosgater

          Hi, The best way I can explain this is to just show you. If you go to this site, http://www.extjs.com/examples/explorer.html#messagebox , (I know its an Ajax framework) and click on any of the buttons (Confirm, Prompt). When you click the button, a dialog box pops up, But the rest of the page fades out and cant be interacted with. This is to bring the users focus onto the dialog box. Now, I know to get the fade effect I have to: 1) add a div to the body tag 2) set its background to black 3) set its opacity to 0.1 4) set its z-index to something like 1000 What I dont understand is how to make it so that the user cannot interact with the other controls on the page. As long as the dialog is showing, the user cannot interact with the rest of the page hidden behind it. But if I add this to my own HTML page. Just a div with width/height 100% and background/opacity black/0.1.. The user can still click buttons or edit textboxes on the page? Does anyone know how is this achieved? Thanks, Andyyy

          P Offline
          P Offline
          plecco
          wrote on last edited by
          #4

          I set up a demo with a similar effect. You can use copy the code and use it... http://plecco.net/labs/modal/

          Plecco Technologies, Inc. Web Design | Software Development | Internet Marketing

          modified on Wednesday, January 27, 2010 9:52 AM

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups