I did on hover , not on click . But this can be altered to click with the help of JavaScript, applying the same styles to click as in my hover pseudo-classes.
For hover this can be done in pure CSS using a single element.
Let's say the image size is 200x200:
*, *:before, *:after { box-sizing: border-box; } .image-popup, .image-popup:before, .image-popup:after { transition: all 0.75s ease; } .image-popup { width: 200px; text-align: center; margin-top: 100px; position: relative; /* ΠΡΡΡΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½Ρ */ border: 0; padding: 0; height: 0; font-size: 0; } .image-popup:before, .image-popup:after { content: ""; width: 200px; height: 100px; /* ΠΠΎΠ»ΠΎΠ²ΠΈΠ½Π° Π²ΡΡΠΎΡΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ */ position: absolute; left: -5px; /* ΠΠ΅Π»ΠΈΡΠΈΠ½Π° border ΠΈΡΡ
ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ */ background: url("https://i.stack.imgur.com/MmtZb.jpg") no-repeat; } .image-popup:before { top: 0; transform: translateY(-100%); /* ΠΠΎΠΌΠ΅ΡΠ°Π΅ΠΌ ΠΏΠΎΠ»-ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Π½Π°Π΄ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠΌ */ } .image-popup:after { bottom: 0; transform: translateY(100%); /* ΠΠΎΠΌΠ΅ΡΠ°Π΅ΠΌ ΠΏΠΎΠ»-ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΏΠΎΠ΄ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠΌ */ background-position: 0 100%; /* ΠΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΠΌ Π½ΠΈΠΆΠ½ΡΡ ΠΏΠΎΠ»ΠΎΠ²ΠΈΠ½Ρ ΠΊΠ°ΡΡΠΈΠ½Ρ */ } /* Π’Π΅ΠΏΠ΅ΡΡ Π΄Π΅Π»Π°Π΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π²ΠΈΠ΄ΠΈΠΌΡΠΌ, ΡΡΡΠ°Π½ΠΎΠ²Π»ΠΈΠ²Π°Ρ border, padding, heigth, font-size */ .image-popup:hover { border: 5px solid lime; padding: 20px; height: auto; font-size: 16px; } /* Π‘ΡΠΈΠ»ΠΈ Π΅ΡΠ»ΠΈ Π΅ΡΡΡ Π³ΡΠ°Π½ΠΈΡΡ (border) */ .image-popup:hover:before { top: -5px; } .image-popup:hover:after { bottom:-5px; }
<div class="image-popup"> WHO WE ARE </div>
background-position. Place an invisible block with text between these blocks. - Pyramidhead