IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

[AJAX] Grey Box et opacité de son contenu


Sujet :

JavaScript

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    440
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 440
    Points : 184
    Points
    184
    Par défaut [AJAX] Grey Box et opacité de son contenu
    Bonjour

    J'utilise la fonction suivante pour faire un grey box:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    function grayOut(vis, site, options) {
      // Pass true to gray out screen, false to ungray
      // options are optional.  This is a JSON object with the following (optional) properties
      // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
      // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
      // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
      // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
      // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
      // in any order.  Pass only the properties you need to set.
      var options = options || {}; 
      var zindex = options.zindex || 50;
      var opacity = options.opacity || 70;
      var opaque = (opacity / 100);
      var bgcolor = options.bgcolor || '#000000';
      var dark=document.getElementById('darkenScreenObject');
      if (!dark) {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
        var tbody = document.getElementsByTagName("body")[0];
        var tnode = document.createElement('div');           // Create the layer.
            tnode.style.position='absolute';                 // Position absolutely
            tnode.style.top='0px';                           // In the top
            tnode.style.left='0px';                          // Left corner of the page
            tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
            tnode.style.display='none';                      // Start out Hidden
            tnode.id='darkenScreenObject';                   // Name it so we can find it later
        tbody.appendChild(tnode);                            // Add it to the web page
        dark=document.getElementById('darkenScreenObject');  // Get the object.
      }
      if (vis) {
        // Calculate the page width and height 
        /*if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
            var pageWidth = document.body.scrollWidth+'px';
            var pageHeight = document.body.scrollHeight+'px';
        } else if( document.body.offsetWidth ) {
          var pageWidth = document.body.offsetWidth+'px';
          var pageHeight = document.body.offsetHeight+'px';
        } else {*/
           var pageWidth='100%';
           var pageHeight='100%';
        //}   
        //set the shader to cover the entire page and make it visible.
        dark.style.opacity=opaque;                      
        dark.style.MozOpacity=opaque;                   
        dark.style.filter='alpha(opacity='+opacity+')'; 
        dark.style.zIndex=zindex;        
        dark.style.backgroundColor=bgcolor;  
        dark.style.width= pageWidth;
        dark.style.height= pageHeight;
      } else {
         dark.style.display='none';
      }
    }
    Le problème c'est que tous ce que je mets dedans est affecté par l'opacité. Comment faire pour que le contenu du div semi transparent soit complètement opaque?

    Merci

  2. #2
    Membre confirmé Avatar de zulad
    Homme Profil pro
    creatif
    Inscrit en
    Juin 2007
    Messages
    713
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : creatif

    Informations forums :
    Inscription : Juin 2007
    Messages : 713
    Points : 519
    Points
    519
    Par défaut
    une solution serait de mettre tous les enfants à opacité 100, mais à ce que je vois:

    C'est que si le conteneur est transparent, son contenu le sera aussi forcement. Donc tu ne dois gérer que la transparence d'un sous élément.

    J'imagine une sous couche div qui ferait office de background...
    Aucun de nous n'est seul, Même l'air que nous expirons est inspirés par d'autres...

Discussions similaires

  1. Réponses: 9
    Dernier message: 23/02/2012, 03h26
  2. Enregistrer une picture box avec son contenu
    Par kinkinhxc dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 10/03/2008, 15h36
  3. [C#] Dossier et son contenu.
    Par GéniuS77 dans le forum Windows Forms
    Réponses: 13
    Dernier message: 12/10/2004, 11h05
  4. Comment copier un répertoire et son contenu ?
    Par yoghisan dans le forum API, COM et SDKs
    Réponses: 6
    Dernier message: 20/06/2004, 17h40
  5. Combo box et liste de valeurs contenues dans ma table
    Par TieumB dans le forum C++Builder
    Réponses: 14
    Dernier message: 05/04/2004, 18h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo