Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-08-2013, 05:59 AM   PM User | #1
elitis
Regular Coder

 
Join Date: Sep 2010
Posts: 319
Thanks: 9
Thanked 6 Times in 6 Posts
elitis is an unknown quantity at this point
Getting background to 'fade' while popup is displayed

How would I go about doing this? I'd like to create a "pop up effect", where a div "pops up" and its opacity is 1 while the background is transparent. If I do document.body.style = '0.1'; it makes everything including the div transparent. I've also tried document.getElementById('popup').style.opacity = '1.0'; in addition to setting the body's style but to no avail.
__________________
Coding is a challenge, get used to it
Always remember to debug
Try the guess & check method
Break it down into simple steps
elitis is offline   Reply With Quote
Old 02-08-2013, 06:30 AM   PM User | #2
boyo1991
New Coder

 
Join Date: Nov 2010
Location: i live online.
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
boyo1991 is an unknown quantity at this point
what happens when you do it with an id then? you said it didnt work but didnt specify...

either way, try it using JQuery, JQuery always ends up fixing my thoughts on this... and actually to be more specific: JQuery-UI...

the example id prolly end up using is as follows:
Code:
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>highlight demo</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css">
  <style>
  #toggle {
    width: 100px;
    height: 100px;
    background: #ccc;
  }
  </style>
  <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
</head>
<body>
 
<p>Click anywhere to toggle the box.</p>
<div id="toggle"></div>
 
<script>
$( document ).click(function() {
  $( "#toggle" ).toggle( "highlight" );
});
</script>
 
</body>
</html>
this was found here: http://api.jqueryui.com/highlight-effect/

instead of changing its transparency, change its color, just a thought..
boyo1991 is offline   Reply With Quote
Old 02-08-2013, 06:51 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,172
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Easy.
Code:
<body>
<div id="popon" style="position: absolute; display: none;">
you will put your popon contents here
you can position it with JS (or in the style) and then change to display: block
</div>
<div id="content">
all the rest of the page content goes in here
and *THIS* is the element whose opacity you change
</div>
</body>
</html>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 02-08-2013, 07:29 AM   PM User | #4
elitis
Regular Coder

 
Join Date: Sep 2010
Posts: 319
Thanks: 9
Thanked 6 Times in 6 Posts
elitis is an unknown quantity at this point
Thanks, I was missing the second div.
__________________
Coding is a challenge, get used to it
Always remember to debug
Try the guess & check method
Break it down into simple steps
elitis is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:19 PM.


Advertisement
Log in to turn off these ads.