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 :

Agrandir une image et la centrer


Sujet :

Centrer un élément en CSS

  1. #1
    Membre du Club
    Inscrit en
    Septembre 2008
    Messages
    629
    Détails du profil
    Informations forums :
    Inscription : Septembre 2008
    Messages : 629
    Points : 47
    Points
    47
    Par défaut Agrandir une image et la centrer
    Bonjour

    J'ai un code pour agrandir les images qui fonctionne, mais j'aimerai lui apporter une modification c'est à dire:
    lorsque l'image sa grandir je voudrais que les images se positionne au milieu de l'écran.
    Mon code:
    Code HTML : 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
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    <!DOCTYPE html>
    <html>
    <head>
     
    <style>
    body {
            font-family: Arial, Helvetica, sans-serif;
            background: #000;
    }
    img {
            transition: transform 0.25s ease;
    }
    img:hover {
            -webkit-transform: scale(2.0);
            transform: scale(2.0);
    }
    table {
            border: thin dotted #575b60;
            border-collapse: collapse;
            width: 60%;
            margin-left: 250px;
            margin-top: 150px;
    }
    td {
            border: thin dotted #575b60;
            height: 30px;
            text-align: center;
            background-color: #000;
    }
        </style>
        </head>
     
        <body>
     
     
    <table>
    	<tr>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    		<td>
    			<a href="">
    				<img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg" height="150" width="300" />
    			</a>
    		</td>
    	</tr>
    </table> 
     
        </body>
    </html>
    Je vous remercie
    Max

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    Utilise un plugin de popup/modal.

  3. #3
    Membre du Club
    Inscrit en
    Septembre 2008
    Messages
    629
    Détails du profil
    Informations forums :
    Inscription : Septembre 2008
    Messages : 629
    Points : 47
    Points
    47
    Par défaut
    Bonjour

    Je te remercie mais je me suis redu ici https://jquerymodal.com/

    j'ai récupéré ceci mais sa ne correspond pas à ce que je cherche

    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />

    Tu vas me dire ............

    Max

  4. #4
    Invité
    Invité(e)
    Dernière modification par Invité ; 16/09/2019 à 11h17.

  5. #5
    Membre du Club
    Inscrit en
    Septembre 2008
    Messages
    629
    Détails du profil
    Informations forums :
    Inscription : Septembre 2008
    Messages : 629
    Points : 47
    Points
    47
    Par défaut
    Re bonjour

    Je te remercie pour les liens mais je penser qu’on pouvez le faire directement en CSS sans passer par les plugins.

    Mais bon!

    Merci

  6. #6
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    16 957
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 16 957
    Points : 44 121
    Points
    44 121
    Par défaut
    Bonjour,
    je penser qu’on pouvez le faire directement en CSS
    c'est effectivement faisable sous certaines conditions, notamment que la structure ne change pas et ça c'est un gros MOINS.

    Avec la présentation du code que tu as donné tu pourrais obtenir un effet intéressant.
    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
    tr:nth-child(1) td:nth-child(1) a:focus img {
      transform: translate(100%,100%) scale(2);
    }
    tr:nth-child(1) td:nth-child(2) a:focus img {
      transform: translate(0%,100%) scale(2);
    }
    tr:nth-child(1) td:nth-child(3) a:focus img {
      transform: translate(-100%,100%) scale(2);
    }
    tr:nth-child(2) td:nth-child(1) a:focus img {
      transform: translate(100%,0%) scale(2);
    }
    tr:nth-child(2) td:nth-child(2) a:focus img {
      transform: translate(0%,0%) scale(2);
    }
    tr:nth-child(2) td:nth-child(3) a:focus img {
      transform: translate(-100%,0%) scale(2);
    }
    tr:nth-child(3) td:nth-child(1) a:focus img {
      transform: translate(100%,-100%) scale(2);
    }
    tr:nth-child(3) td:nth-child(2) a:focus img {
      transform: translate(0%,-100%) scale(2);
    }
    tr:nth-child(3) td:nth-child(3) a:focus img {
      transform: translate(-100%,-100%) scale(2);
    }
    ceci étant à supprimer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    img:hover {
      transform: scale(2.0);
    }
    Donc c'est faisable mais cela peut devenir vite imbuvable.

    Le mieux restant l'utilisation d'un code tout fait il en existe de vraiment simple à mettre en oeuvre, de plus ils s’adapteront plus facilement à tes structures pas toujours très limpides.

    Nota : pourquoi des balises <a> dans ton code, dans le cas présent cela arrange ?

Discussions similaires

  1. Agrandir une image dans un contrôle "static"
    Par Silverstone dans le forum Windows
    Réponses: 3
    Dernier message: 19/07/2006, 13h45
  2. [VB6] Me permettre d'agrandir une IMAGE
    Par Lucas42 dans le forum VB 6 et antérieur
    Réponses: 28
    Dernier message: 03/05/2006, 18h56
  3. Agrandir une image au passage de la souris
    Par matika dans le forum C++Builder
    Réponses: 7
    Dernier message: 09/03/2006, 00h10
  4. Réponses: 3
    Dernier message: 19/01/2006, 14h08
  5. [Java2D]Agrandir une image
    Par Guybrush dans le forum 2D
    Réponses: 8
    Dernier message: 02/11/2005, 10h36

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