U need to turn off overflow of the image. Also the image should be 100% width of its parent. The trigger button is in the container that closes, so you must move it away. And I used simple JS function to add a class to open it and close.
I’m trying to close and open an image with HTML/CSS.
Comments
Comment posted by A Haworth
Could you describe exactly what ‘not working’ means here. Also have you checked that you definitely have the right paths for those images?
Comment posted by leoprosy
@AHaworth the paths are good it’s not the problem I wanted to mean that the image doesn’t go to 0 of height on click
Comment posted by tacoshy
For that you should use either JS or a CSS-only solution a “hack” by wrapping the image in a label connected to a checkbox
Comment posted by A Haworth
I can’t make sense of your code (even correcting for the fact you are using a class rather than the close id). When close is active you give it an animation, but it’s the other img you want to shrink to nothing on the click isn’t it? And do you want it to remain shrunk?
Comment posted by leoprosy
@AHaworth yes. If possible I want to shrink the div and the image in the same time. I tried with javascript but not working
Comment posted by tacoshy
You should not use the
Comment posted by A Haworth
@tacoshy could you explain the reson for not using double quotes in JS? I had not heard that before (and actually thought JS strings were marginally preferably double quoted because of the single quote also being used so much in things like isn’t in English.
Comment posted by mdabrowski
@tacoshy Thanks for contributing. I’m still learning and in fact I use stack to learn even more. All the tips are implemented now.