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

Mise en page CSS Discussion :

checkbox qui active un hover actif


Sujet :

Survol d'un élément en CSS (:hover)

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 165
    Points : 0
    Points
    0
    Par défaut checkbox qui active un hover actif
    Bonjour à tous !

    je pense que le problème se résout en css. Voici le code que j'ai :

    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
    <style>
    .videos_astuces
    {
    width:900px;
    height:18px;
    overflow:hidden;
    transition: height 1s; 
    -moz-transition: height 1s;
    -webkit-transition: height 1s;
    -o-transition: height 1s;
    border: 1px solid #0060F0;
    border-radius: 5px;  
    }
     
    .videos_astuces:hover
    {
    height:524px;
    }
    .menu_deroulant_astuce
    {
    color:black;
    background-color:#FF8C00;
    }
    .checkbox
    {float:right;
    }
    </style>
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <br />
    <div class="videos_astuces">
    <div class="menu_deroulant_astuce">
    <span style="font-family: Verdana, sans-serif;">Changer le volume d'une chanson et l'exporter en mp3 avec Audacity</span>
    <input type="checkbox" class="checkbox"><span class="checkbox" style="font-family: Verdana, sans-serif;">Laisser ouvert</span>
    </div>
    <div class="content_box" style="overflow: none;">
    <iframe frameborder="0" height="506" src="http://www.youtube.com/embed/1cefBcHaz_U" width="100%"></iframe></div>
    </div>

    Il est sûrement possible en CSS de résoudre mon problème : lorsque j'active le chekbox "laisser ouvert", je voudrai que le hover reste actif (soit ouvert) et réciproquement mais comment ?
    Si quelqu'un peut me donner le bout de code qui permet de résoudre ceci, je l'admirai énormément !
    Merci d'avance.

    Pito2901

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,
    Avec quelques aménagements du code :
    Code css : 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
    .videos_astuces
    {
    width:900px;
    overflow:hidden;
    border: 1px solid #0060F0;
    border-radius: 5px;  
    color:black;
    background-color:#FF8C00;
    }
     
    .videos_astuces .content_box
    {
    height:0px;
    overflow:hidden;
    transition: height 1s; 
    -moz-transition: height 1s;
    -webkit-transition: height 1s;
    -o-transition: height 1s;
    }
    .checkbox
    { 
    float:right;
    }
     
    .videos_astuces:hover .content_box, 
    .videos_astuces .content_box:hover,
    .videos_astuces input[type=checkbox]:checked + .content_box
    {
    height:506px;
    }
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <div class="videos_astuces">
    	<span style="font-family: Verdana, sans-serif;">Changer le volume d'une chanson et l'exporter en mp3 avec Audacity</span>
    	<input class="checkbox" type="checkbox" title="Laisser ouvert"/>
    	<div class="content_box">
    		<iframe frameborder="0" height="506" src="http://www.youtube.com/embed/1cefBcHaz_U" width="100%"></iframe>
    	</div>
    </div>
    L'astuce (!) est ici : input[type=checkbox]:checked + .content_box
    => CSS Selectors : Adjacent sibling selectors

    Et hop ! Un admirateur de plus !
    Dernière modification par Invité ; 25/08/2013 à 11h34.

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 165
    Points : 0
    Points
    0
    Par défaut
    Super sympa, merci ça marche !

    J'ai encore une question, est-il possible qu'on ne voit pas cette bande orange sur le long de la vidéo qui en fait est là à cause du checkbox, sachant que celui-ci doit resté à droite {float:right}. Je pense qu'il y a une histoire de mettre la vidéo en premier plan, mais malheureusement je ne maîtrise pas le sujet...
    Avez-vous une solution ?

  4. #4
    Invité
    Invité(e)
    Par défaut
    Quelle "bande orange" ?

    background-color:#FF8C00; ?

  5. #5
    Expert confirmé
    Avatar de rodolphebrd
    Homme Profil pro
    Indépendant
    Inscrit en
    Novembre 2012
    Messages
    2 336
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Indépendant
    Secteur : Conseil

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 336
    Points : 5 443
    Points
    5 443
    Par défaut
    En modifiant un peu le HTML je verrais ça :

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <div class="videos_astuces">
    	<input class="checkbox" type="checkbox" title="Laisser ouvert"/>
      <span class="txt" style="font-family: Verdana, sans-serif;">Changer le volume d'une chanson et l'exporter en mp3 avec Audacity</span>
    	<div class="content_box">
    		<iframe frameborder="0" height="506" src="http://www.youtube.com/embed/1cefBcHaz_U" width="100%"></iframe>
    	</div>
    </div>
    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
    .videos_astuces
    {
    position: relative;
    width:900px;
    overflow:hidden;
    border: 1px solid #0060F0;
    border-radius: 5px;  
    color:black;
    background-color:#FF8C00;
    }
     
    .videos_astuces .content_box
    {
    height:0px;
    overflow:hidden;
    transition: height 1s; 
    -moz-transition: height 1s;
    -webkit-transition: height 1s;
    -o-transition: height 1s;
    }
    .checkbox
    { 
    float:right;
    }
     
    .videos_astuces:hover .content_box, 
    .videos_astuces .content_box:hover,
    .videos_astuces input[type=checkbox]:checked + span + .content_box
    {
       height:506px;
    }
    input[type=checkbox]:checked + .txt {
       display:none;
    }
     input[type=checkbox]:checked.checkbox  {
      position : absolute;
      right:0;
    }
    http://codepen.io/anon/pen/FogGf

  6. #6
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 165
    Points : 0
    Points
    0
    Par défaut
    Merci, c'est ce que je voulais, mais si possible, est-ce qu'on peut laisser le titre "changer le volume..." et la vidéo en dessous une fois le checkbox activé ?

  7. #7
    Expert confirmé
    Avatar de rodolphebrd
    Homme Profil pro
    Indépendant
    Inscrit en
    Novembre 2012
    Messages
    2 336
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Indépendant
    Secteur : Conseil

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 336
    Points : 5 443
    Points
    5 443
    Par défaut
    Alors:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    input[type=checkbox]:checked + .txt {
      position : absolute;
      color:white;
    }
    http://codepen.io/anon/pen/Hodwf

  8. #8
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 165
    Points : 0
    Points
    0
    Par défaut
    C'est bon, j'ai trouvé !

    Code css : 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
     
    .videos_astuces
    {
       position: relative;
       width:880px;
       overflow:hidden;
       border: 1px solid #0060F0;
       border-radius: 5px;  
       color:black;
       background-color:#FF8C00;
    }
     
    .videos_astuces .content_box
    {
       height:0px;width:880px;
       overflow:hidden;
       transition: height 1s; 
       -moz-transition: height 1s;
       -webkit-transition: height 1s;
       -o-transition: height 1s;
    }
    .checkbox
    { 
       float:right;
    }
     
    .videos_astuces:hover .content_box, 
    .videos_astuces .content_box:hover,
    .videos_astuces input[type=checkbox]:checked + span + .content_box
    {
       height:524px;
    }
    input[type=checkbox]:checked.checkbox  {
      position : absolute;
      right:0;
    }

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <br />
    <div class="videos_astuces">
    	<input class="checkbox" type="checkbox" title="Laisser ouvert"/>
      <span class="txt" style="font-family: Verdana, sans-serif;">Changer le volume d'une chanson et l'exporter en mp3 avec Audacity</span>
    	<div class="content_box">
    		<iframe frameborder="0" height="524" src="http://www.youtube.com/embed/1cefBcHaz_U" width="100%"></iframe>
    	</div>
    </div>

    Merci encore à tous !

  9. #9
    Expert confirmé
    Avatar de rodolphebrd
    Homme Profil pro
    Indépendant
    Inscrit en
    Novembre 2012
    Messages
    2 336
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Indépendant
    Secteur : Conseil

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 336
    Points : 5 443
    Points
    5 443
    Par défaut
    Euh, apparemment vous êtes revenu au point de départ

  10. #10
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2013
    Messages
    165
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2013
    Messages : 165
    Points : 0
    Points
    0
    Par défaut
    Non, je voulais juste que le div reste ouvert, mais pas que la vidéo "écrase" le span

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. CheckBox qui activer la musique
    Par JudoDx99 dans le forum Débuter
    Réponses: 1
    Dernier message: 21/04/2015, 16h16
  2. :hover qui active deux codes CSS différents
    Par Décibel dans le forum Mise en page CSS
    Réponses: 5
    Dernier message: 01/03/2015, 00h10
  3. checkbox qui reste actives
    Par Chris_Dupasquier dans le forum VB.NET
    Réponses: 5
    Dernier message: 04/05/2010, 16h31
  4. [VBA-E]Probleme checkbox qui reste cochée
    Par Elstak dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 03/05/2006, 11h39
  5. quels sont les checkbox qui sont cochés?
    Par debutant.informatique dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 16/03/2006, 21h18

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